<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zigbee Dimmable light bulb with electrical measurement</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64936/zigbee-dimmable-light-bulb-with-electrical-measurement</link><description>Hello I&amp;#39;m working with Zigbee Dimmable Bulb example. Testing environment is as followed: 
 nRF52840DK SmartThings Gateway SmartThings iOS app. 
 After changing the Zigbee channel to 14 in the example everything works great. The problem occurred when I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 Aug 2020 13:24:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64936/zigbee-dimmable-light-bulb-with-electrical-measurement" /><item><title>RE: Zigbee Dimmable light bulb with electrical measurement</title><link>https://devzone.nordicsemi.com/thread/266516?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 13:24:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a26ee41-4231-44cf-ae84-1add6b69b010</guid><dc:creator>tomchy</dc:creator><description>&lt;p&gt;Hello Jakub,&lt;br /&gt;updating the attribute value triggers sending frames only if there is an active reporting configuration for that specific attribute.&lt;/p&gt;
&lt;p&gt;Please verify that the hub has configured both the binding and the reporting configuration for the DCPOWER attribute.&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Tomchy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee Dimmable light bulb with electrical measurement</title><link>https://devzone.nordicsemi.com/thread/265411?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 18:27:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a780ab72-f78a-4112-8951-34a635e96c79</guid><dc:creator>jwitowski</dc:creator><description>&lt;p&gt;Some debug logs:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: zcl_device_cb id 0
&amp;lt;info&amp;gt; app: Set ON/OFF value: 1
&amp;lt;info&amp;gt; zboss:  DE AD 12 02 E5 28 B3 00|.....(..
&amp;lt;info&amp;gt; zboss:  01 00 00 00 DE AD 0E 02|........
&amp;lt;info&amp;gt; zboss:  04 00 00 00 DE AD 12 02|........
&amp;lt;info&amp;gt; zboss:  06 00 00 00 01 00 00 00|........
&amp;lt;info&amp;gt; app: Set DC POWER value: 1
&amp;lt;info&amp;gt; zboss:  DE AD 12 02 E5 28 B5 00|.....(..
&amp;lt;info&amp;gt; zboss:  01 00 00 00 DE AD 12 02|........
&amp;lt;info&amp;gt; zboss:  E5 28 B6 00 1A 08 75 01|.(....u.
&amp;lt;info&amp;gt; app: Set level value: 255
&amp;lt;info&amp;gt; zboss:  DE AD 12 02 E5 28 B7 00|.....(..
&amp;lt;info&amp;gt; zboss:  1A 08 60 01 08 00 00 00|..`.....
&amp;lt;info&amp;gt; zboss:  01 00 00 00 DE AD 12 02|........
&amp;lt;info&amp;gt; zboss:  E5 28 B8 00 1A 08 75 01|.(....u.
&amp;lt;info&amp;gt; zboss:  DE AD 12 02 E5 28 B9 00|.....(..
&amp;lt;info&amp;gt; zboss:  01 00 00 00 DE AD 12 02|........
&amp;lt;info&amp;gt; zboss:  06 00 00 00 01 00 00 00|........
&amp;lt;info&amp;gt; app: zcl_device_cb status: 0
&amp;lt;info&amp;gt; zboss:  DE AD 12 02 E5 28 BB 00|.....(..
&amp;lt;info&amp;gt; zboss:  01 00 00 00 DE AD 12 02|........
&amp;lt;info&amp;gt; zboss:  E5 28 BC 00 1A 08 75 01|.(....u.
&amp;lt;info&amp;gt; zboss:  06 00 00 00 01 00 00 00|........&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee Dimmable light bulb with electrical measurement</title><link>https://devzone.nordicsemi.com/thread/265372?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 14:45:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e61faf86-4ec6-4fd4-a6b4-a68d4c0a8b18</guid><dc:creator>jwitowski</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;yes I want to add the electrical measurement cluster to the light bulb cluster.&lt;/p&gt;
&lt;p&gt;I have updated the &lt;strong&gt;zb_ha_dimmable_light.h&lt;/strong&gt; with:&lt;br /&gt; - incrementing the ZB_HA_DIMMABLE_LIGHT_IN_CLUSTER_NUM by 1.&lt;br /&gt;- adding ZB_ZCL_ELECTRICAL_MEASUREMENT_REPORT_ATTR_COUNT to the ZB_HA_DIMMABLE_LIGHT_REPORT_ATTR_COUNT&lt;br /&gt;- adding el_meas_attr_list to the ZB_HA_DECLARE_DIMMABLE_LIGHT_CLUSTER_LIST&lt;br /&gt;- adding ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT to the ZB_ZCL_DECLARE_HA_DIMMABLE_LIGHT_SIMPLE_DESC&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After those changes the application started but I cannot notice any electrical measurement related data in the sniffer:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1597849369345v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;As You can see in the code, the electrical measurement should be sent with on/off.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The updated main.c and zb_ha_dimmable_light.h you can se in the attached code.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#include &amp;quot;sdk_config.h&amp;quot;
#include &amp;quot;zboss_api.h&amp;quot;
#include &amp;quot;zboss_api_addons.h&amp;quot;
#include &amp;quot;zb_mem_config_med.h&amp;quot;
#include &amp;quot;zb_ha_dimmable_light.h&amp;quot;
#include &amp;quot;zb_zcl_el_measurement.h&amp;quot;
#include &amp;quot;zb_error_handler.h&amp;quot;
#include &amp;quot;zb_nrf52_internal.h&amp;quot;
#include &amp;quot;zigbee_helpers.h&amp;quot;

#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_pwm.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

#define MAX_CHILDREN                      10                                    /**&amp;lt; The maximum amount of connected devices. Setting this value to 0 disables association to this device.  */
#define IEEE_CHANNEL_MASK                 (1l &amp;lt;&amp;lt; ZIGBEE_CHANNEL)                /**&amp;lt; Scan only one, predefined channel to find the coordinator. */
#define HA_DIMMABLE_LIGHT_ENDPOINT        10                                    /**&amp;lt; Device endpoint, used to receive light controlling commands. */
#define ERASE_PERSISTENT_CONFIG           ZB_FALSE                              /**&amp;lt; Do not erase NVRAM to save the network parameters after device reboot or power-off. */
#define BULB_PWM_NAME                     PWM1                                  /**&amp;lt; PWM instance used to drive dimmable light bulb. */
#define BULB_PWM_TIMER                    2                                     /**&amp;lt; Timer number used by PWM. */

/* Basic cluster attributes initial values. */
#define BULB_INIT_BASIC_APP_VERSION       01                                    /**&amp;lt; Version of the application software (1 byte). */
#define BULB_INIT_BASIC_STACK_VERSION     10                                    /**&amp;lt; Version of the implementation of the Zigbee stack (1 byte). */
#define BULB_INIT_BASIC_HW_VERSION        11                                    /**&amp;lt; Version of the hardware of the device (1 byte). */
#define BULB_INIT_BASIC_MANUF_NAME        &amp;quot;Nordic&amp;quot;                              /**&amp;lt; Manufacturer name (32 bytes). */
#define BULB_INIT_BASIC_MODEL_ID          &amp;quot;Dimable_Light_v0.1&amp;quot;                  /**&amp;lt; Model number assigned by manufacturer (32-bytes long string). */
#define BULB_INIT_BASIC_DATE_CODE         &amp;quot;20180416&amp;quot;                            /**&amp;lt; First 8 bytes specify the date of manufacturer of the device in ISO 8601 format (YYYYMMDD). The rest (8 bytes) are manufacturer specific. */
#define BULB_INIT_BASIC_POWER_SOURCE      ZB_ZCL_BASIC_POWER_SOURCE_DC_SOURCE   /**&amp;lt; Type of power sources available for the device. For possible values see section 3.2.2.2.8 of ZCL specification. */
#define BULB_INIT_BASIC_LOCATION_DESC     &amp;quot;Office desk&amp;quot;                         /**&amp;lt; Describes the physical location of the device (16 bytes). May be modified during commisioning process. */
#define BULB_INIT_BASIC_PH_ENV            ZB_ZCL_BASIC_ENV_UNSPECIFIED          /**&amp;lt; Describes the type of physical environment. For possible values see section 3.2.2.2.10 of ZCL specification. */

#define IDENTIFY_MODE_BSP_EVT             BSP_EVENT_KEY_3                       /**&amp;lt; Button event used to enter the Bulb into the Identify mode. */
#define ZIGBEE_NETWORK_STATE_LED          BSP_BOARD_LED_2                       /**&amp;lt; LED indicating that light switch successfully joind Zigbee network. */
#define BULB_LED                          BSP_BOARD_LED_3                       /**&amp;lt; LED immitaing dimmable light bulb. */

/* Declare endpoint for Dimmable Light device with scenes. */
#define ZB_HA_DECLARE_LIGHT_EP(ep_name, ep_id, cluster_list)                         \
  ZB_ZCL_DECLARE_HA_DIMMABLE_LIGHT_SIMPLE_DESC(ep_name, ep_id,                       \
    ZB_HA_DIMMABLE_LIGHT_IN_CLUSTER_NUM, ZB_HA_DIMMABLE_LIGHT_OUT_CLUSTER_NUM);      \
  ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name,               \
                                     ZB_HA_DIMMABLE_LIGHT_REPORT_ATTR_COUNT);        \
  ZBOSS_DEVICE_DECLARE_LEVEL_CONTROL_CTX(cvc_alarm_info## device_ctx_name,           \
                                         ZB_HA_DIMMABLE_LIGHT_CVC_ATTR_COUNT);       \
  ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, ZB_AF_HA_PROFILE_ID,                   \
                              0,                                                     \
                              NULL,                                                  \
                              ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t),\
                              cluster_list,                                          \
                              (zb_af_simple_desc_1_1_t*)&amp;amp;simple_desc_##ep_name,      \
                              ZB_HA_DIMMABLE_LIGHT_REPORT_ATTR_COUNT,                \
                              reporting_info## device_ctx_name,                      \
                              ZB_HA_DIMMABLE_LIGHT_CVC_ATTR_COUNT,                   \
                              cvc_alarm_info## device_ctx_name)

#if !defined ZB_ROUTER_ROLE
#error Define ZB_ROUTER_ROLE to compile light bulb (Router) source code.
#endif

typedef struct
{
    zb_uint32_t measurement_type;
    zb_int16_t  dc_power;
} zb_zcl_electrical_measurement_attrs_t;

/* Main application customizable context. Stores all settings and static values. */
typedef struct
{
    zb_zcl_basic_attrs_ext_t              basic_attr;
    zb_zcl_identify_attrs_t               identify_attr;
    zb_zcl_scenes_attrs_t                 scenes_attr;
    zb_zcl_groups_attrs_t                 groups_attr;
    zb_zcl_on_off_attrs_ext_t             on_off_attr;
    zb_zcl_level_control_attrs_t          level_control_attr;
    zb_zcl_electrical_measurement_attrs_t el_meas_attr;
} bulb_device_ctx_t;


APP_PWM_INSTANCE(BULB_PWM_NAME, BULB_PWM_TIMER);
static bulb_device_ctx_t m_dev_ctx;

/* ATTRIBUTES */
ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(identify_attr_list, &amp;amp;m_dev_ctx.identify_attr.identify_time);


ZB_ZCL_DECLARE_GROUPS_ATTRIB_LIST(groups_attr_list, &amp;amp;m_dev_ctx.groups_attr.name_support);

ZB_ZCL_DECLARE_SCENES_ATTRIB_LIST(scenes_attr_list,
                                  &amp;amp;m_dev_ctx.scenes_attr.scene_count,
                                  &amp;amp;m_dev_ctx.scenes_attr.current_scene,
                                  &amp;amp;m_dev_ctx.scenes_attr.current_group,
                                  &amp;amp;m_dev_ctx.scenes_attr.scene_valid,
                                  &amp;amp;m_dev_ctx.scenes_attr.name_support);

ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT(basic_attr_list,
                                     &amp;amp;m_dev_ctx.basic_attr.zcl_version,
                                     &amp;amp;m_dev_ctx.basic_attr.app_version,
                                     &amp;amp;m_dev_ctx.basic_attr.stack_version,
                                     &amp;amp;m_dev_ctx.basic_attr.hw_version,
                                     m_dev_ctx.basic_attr.mf_name,
                                     m_dev_ctx.basic_attr.model_id,
                                     m_dev_ctx.basic_attr.date_code,
                                     &amp;amp;m_dev_ctx.basic_attr.power_source,
                                     m_dev_ctx.basic_attr.location_id,
                                     &amp;amp;m_dev_ctx.basic_attr.ph_env,
                                     m_dev_ctx.basic_attr.sw_ver);

ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST_EXT(on_off_attr_list,
                                      &amp;amp;m_dev_ctx.on_off_attr.on_off,
                                      &amp;amp;m_dev_ctx.on_off_attr.global_scene_ctrl,
                                      &amp;amp;m_dev_ctx.on_off_attr.on_time,
                                      &amp;amp;m_dev_ctx.on_off_attr.off_wait_time);

ZB_ZCL_DECLARE_LEVEL_CONTROL_ATTRIB_LIST(level_control_attr_list,
                                         &amp;amp;m_dev_ctx.level_control_attr.current_level,
                                         &amp;amp;m_dev_ctx.level_control_attr.remaining_time);

ZB_ZCL_DECLARE_ELECTRICAL_MEASUREMENT_ATTRIB_LIST(el_meas_attr_list,
                                                  &amp;amp;m_dev_ctx.el_meas_attr.measurement_type,
                                                  &amp;amp;m_dev_ctx.el_meas_attr.dc_power);

ZB_HA_DECLARE_DIMMABLE_LIGHT_CLUSTER_LIST(dimmable_light_clusters,
                                          basic_attr_list,
                                          identify_attr_list,
                                          groups_attr_list,
                                          scenes_attr_list,
                                          on_off_attr_list,
                                          level_control_attr_list,
                                          el_meas_attr_list);

ZB_HA_DECLARE_LIGHT_EP(dimmable_light_ep,
                       HA_DIMMABLE_LIGHT_ENDPOINT,
                       dimmable_light_clusters);

ZB_HA_DECLARE_DIMMABLE_LIGHT_CTX(dimmable_light_ctx,
                                 dimmable_light_ep);

/**@brief Function for initializing the application timer.
 */
static void timer_init(void)
{
    uint32_t error_code = app_timer_init();
    APP_ERROR_CHECK(error_code);
}

/**@brief Function for initializing the nrf log module.
 */
static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}

/**@brief Sets brightness of on-board LED
 *
 * @param[in] brightness_level Brightness level, allowed values 0 ... 255, 0 - turn off, 255 - full brightness
 */
static void light_bulb_onboard_set_brightness(zb_uint8_t brightness_level)
{
    app_pwm_duty_t app_pwm_duty;

    /* Scale level value: APP_PWM uses 0-100 scale, but Zigbee level control cluster uses values from 0 up to 255. */
    app_pwm_duty = (brightness_level * 100U) / 255U;

    /* Set the duty cycle - keep trying until PWM is ready. */
    while (app_pwm_channel_duty_set(&amp;amp;BULB_PWM_NAME, 0, app_pwm_duty) == NRF_ERROR_BUSY)
    {
    }
}

/**@brief Sets brightness of bulb luminous executive element
 *
 * @param[in] brightness_level Brightness level, allowed values 0 ... 255, 0 - turn off, 255 - full brightness
 */
static void light_bulb_set_brightness(zb_uint8_t brightness_level)
{
    light_bulb_onboard_set_brightness(brightness_level);
}

/**@brief Function for setting the light bulb brightness.
  *
  * @param[in]   new_level   Light bulb brightness value.
 */
static void level_control_set_value(zb_uint16_t new_level)
{
    NRF_LOG_INFO(&amp;quot;Set level value: %i&amp;quot;, new_level);

    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT,                                       
                         ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,            
                         ZB_ZCL_CLUSTER_SERVER_ROLE,                 
                         ZB_ZCL_ATTR_LEVEL_CONTROL_CURRENT_LEVEL_ID, 
                         (zb_uint8_t *)&amp;amp;new_level,                                       
                         ZB_FALSE);                                  

    /* According to the table 7.3 of Home Automation Profile Specification v 1.2 rev 29, chapter 7.1.3. */
    if (new_level == 0)
    {
        zb_uint8_t value = ZB_FALSE;
        ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT, 
                             ZB_ZCL_CLUSTER_ID_ON_OFF,    
                             ZB_ZCL_CLUSTER_SERVER_ROLE,  
                             ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
                             &amp;amp;value,                        
                             ZB_FALSE);                   
    }
    else
    {
        zb_uint8_t value = ZB_TRUE;
        ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT, 
                             ZB_ZCL_CLUSTER_ID_ON_OFF,    
                             ZB_ZCL_CLUSTER_SERVER_ROLE,  
                             ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
                             &amp;amp;value,                        
                             ZB_FALSE);
    }

    light_bulb_set_brightness(new_level);
}


/**@brief Function for turning ON/OFF the light bulb.
 *
 * @param[in]   on   Boolean light bulb state.
 */
static void on_off_set_value(zb_bool_t on)
{
    NRF_LOG_INFO(&amp;quot;Set ON/OFF value: %i&amp;quot;, on);

    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT, 
                         ZB_ZCL_CLUSTER_ID_ON_OFF,    
                         ZB_ZCL_CLUSTER_SERVER_ROLE,  
                         ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
                         (zb_uint8_t *)&amp;amp;on,                        
                         ZB_FALSE);

    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT, 
                         ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT,    
                         ZB_ZCL_CLUSTER_SERVER_ROLE,  
                         ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID,
                         (zb_uint8_t *)&amp;amp;on,                        
                         ZB_FALSE);

    if (on)
    {
        level_control_set_value(m_dev_ctx.level_control_attr.current_level);
    }
    else
    {
        light_bulb_set_brightness(0U);
    }
}

/**@brief Callback for button events.
 *
 * @param[in]   evt      Incoming event from the BSP subsystem.
 */
static void buttons_handler(bsp_event_t evt)
{
    zb_ret_t zb_err_code;

    switch(evt)
    {
        case IDENTIFY_MODE_BSP_EVT:
            /* Check if endpoint is in identifying mode, if not put desired endpoint in identifying mode. */
            if (m_dev_ctx.identify_attr.identify_time == ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE)
            {
                NRF_LOG_INFO(&amp;quot;Bulb put in identifying mode&amp;quot;);
                zb_err_code = zb_bdb_finding_binding_target(HA_DIMMABLE_LIGHT_ENDPOINT);
                ZB_ERROR_CHECK(zb_err_code);
            }
            else
            {
                NRF_LOG_INFO(&amp;quot;Cancel F&amp;amp;B target procedure&amp;quot;);
                zb_bdb_finding_binding_target_cancel();
            }
            break;

        default:
            NRF_LOG_INFO(&amp;quot;Unhandled BSP Event received: %d&amp;quot;, evt);
            break;
    }
}


/**@brief Function for initializing LEDs and a single PWM channel.
 */
static void leds_buttons_init(void)
{
    ret_code_t       err_code;
    app_pwm_config_t pwm_cfg = APP_PWM_DEFAULT_CONFIG_1CH(5000L, bsp_board_led_idx_to_pin(BULB_LED));

    /* Initialize all LEDs and buttons. */
    err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, buttons_handler);
    APP_ERROR_CHECK(err_code);
    /* By default the bsp_init attaches BSP_KEY_EVENTS_{0-4} to the PUSH events of the corresponding buttons. */

    /* Initialize PWM running on timer 1 in order to control dimmable light bulb. */
    err_code = app_pwm_init(&amp;amp;BULB_PWM_NAME, &amp;amp;pwm_cfg, NULL);
    APP_ERROR_CHECK(err_code);

    app_pwm_enable(&amp;amp;BULB_PWM_NAME);

    while (app_pwm_channel_duty_set(&amp;amp;BULB_PWM_NAME, 0, 99) == NRF_ERROR_BUSY)
    {
    }
}

/**@brief Function for initializing all clusters attributes.
 */
static void bulb_clusters_attr_init(void)
{
    /* Basic cluster attributes data */
    m_dev_ctx.basic_attr.zcl_version   = ZB_ZCL_VERSION;
    m_dev_ctx.basic_attr.app_version   = BULB_INIT_BASIC_APP_VERSION;
    m_dev_ctx.basic_attr.stack_version = BULB_INIT_BASIC_STACK_VERSION;
    m_dev_ctx.basic_attr.hw_version    = BULB_INIT_BASIC_HW_VERSION;

    /* Use ZB_ZCL_SET_STRING_VAL to set strings, because the first byte should
     * contain string length without trailing zero.
     *
     * For example &amp;quot;test&amp;quot; string wil be encoded as:
     *   [(0x4), &amp;#39;t&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;s&amp;#39;, &amp;#39;t&amp;#39;]
     */
    ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.mf_name,
                          BULB_INIT_BASIC_MANUF_NAME,
                          ZB_ZCL_STRING_CONST_SIZE(BULB_INIT_BASIC_MANUF_NAME));

    ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.model_id,
                          BULB_INIT_BASIC_MODEL_ID,
                          ZB_ZCL_STRING_CONST_SIZE(BULB_INIT_BASIC_MODEL_ID));

    ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.date_code,
                          BULB_INIT_BASIC_DATE_CODE,
                          ZB_ZCL_STRING_CONST_SIZE(BULB_INIT_BASIC_DATE_CODE));

    m_dev_ctx.basic_attr.power_source = BULB_INIT_BASIC_POWER_SOURCE;

    ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.location_id,
                          BULB_INIT_BASIC_LOCATION_DESC,
                          ZB_ZCL_STRING_CONST_SIZE(BULB_INIT_BASIC_LOCATION_DESC));


    m_dev_ctx.basic_attr.ph_env = BULB_INIT_BASIC_PH_ENV;

    /* Identify cluster attributes data */
    m_dev_ctx.identify_attr.identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;

    /* On/Off cluster attributes data */
    m_dev_ctx.on_off_attr.on_off = (zb_bool_t)ZB_ZCL_ON_OFF_IS_ON;

    m_dev_ctx.level_control_attr.current_level  = ZB_ZCL_LEVEL_CONTROL_LEVEL_MAX_VALUE;
    m_dev_ctx.level_control_attr.remaining_time = ZB_ZCL_LEVEL_CONTROL_REMAINING_TIME_DEFAULT_VALUE;

    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT, 
                         ZB_ZCL_CLUSTER_ID_ON_OFF,    
                         ZB_ZCL_CLUSTER_SERVER_ROLE,  
                         ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
                         (zb_uint8_t *)&amp;amp;m_dev_ctx.on_off_attr.on_off,                        
                         ZB_FALSE);                   

    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT,                                       
                         ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,            
                         ZB_ZCL_CLUSTER_SERVER_ROLE,                 
                         ZB_ZCL_ATTR_LEVEL_CONTROL_CURRENT_LEVEL_ID, 
                         (zb_uint8_t *)&amp;amp;m_dev_ctx.level_control_attr.current_level,                                       
                         ZB_FALSE);


    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT,
                         ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT,
                         ZB_ZCL_CLUSTER_SERVER_ROLE,
                         ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID,
                         (zb_uint8_t *)&amp;amp;m_dev_ctx.el_meas_attr.dc_power,
                         ZB_FALSE);
}

/**@brief Function which tries to sleep down the MCU 
 *
 * Function which sleeps the MCU on the non-sleepy End Devices to optimize the power saving.
 * The weak definition inside the OSIF layer provides some minimal working template
 */
zb_void_t zb_osif_go_idle(zb_void_t)
{
    //TODO: implement your own logic if needed
    zb_osif_wait_for_event();
}

/**@brief Callback function for handling ZCL commands.
 *
 * @param[in]   bufid   Reference to Zigbee stack buffer used to pass received data.
 */
static zb_void_t zcl_device_cb(zb_bufid_t bufid)
{
    zb_uint8_t                       cluster_id;
    zb_uint8_t                       attr_id;
    zb_zcl_device_callback_param_t * p_device_cb_param = ZB_BUF_GET_PARAM(bufid, zb_zcl_device_callback_param_t);

    NRF_LOG_INFO(&amp;quot;zcl_device_cb id %hd&amp;quot;, p_device_cb_param-&amp;gt;device_cb_id);

    /* Set default response value. */
    p_device_cb_param-&amp;gt;status = RET_OK;

    switch (p_device_cb_param-&amp;gt;device_cb_id)
    {
        case ZB_ZCL_LEVEL_CONTROL_SET_VALUE_CB_ID:
        {
            NRF_LOG_INFO(&amp;quot;Level control setting to %d&amp;quot;, p_device_cb_param-&amp;gt;cb_param.level_control_set_value_param.new_value);
            level_control_set_value(p_device_cb_param-&amp;gt;cb_param.level_control_set_value_param.new_value);
            break;
        }

        case ZB_ZCL_SET_ATTR_VALUE_CB_ID:
        {
            cluster_id = p_device_cb_param-&amp;gt;cb_param.set_attr_value_param.cluster_id;
            attr_id    = p_device_cb_param-&amp;gt;cb_param.set_attr_value_param.attr_id;

            if (cluster_id == ZB_ZCL_CLUSTER_ID_ON_OFF)
            {
                uint8_t value = p_device_cb_param-&amp;gt;cb_param.set_attr_value_param.values.data8;

                NRF_LOG_INFO(&amp;quot;on/off attribute setting to %hd&amp;quot;, value);
                if (attr_id == ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID)
                {
                    on_off_set_value((zb_bool_t) value);
                }
            }
            else if (cluster_id == ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL)
            {
                uint16_t value = p_device_cb_param-&amp;gt;cb_param.set_attr_value_param.values.data16;

                NRF_LOG_INFO(&amp;quot;level control attribute setting to %hd&amp;quot;, value);
                if (attr_id == ZB_ZCL_ATTR_LEVEL_CONTROL_CURRENT_LEVEL_ID)
                {
                    level_control_set_value(value);
                }
            }
            else
            {
                /* Other clusters can be processed here */
                NRF_LOG_INFO(&amp;quot;Unhandled cluster attribute id: %d&amp;quot;, cluster_id);
            }
            break;
        }

        default:
        {
            p_device_cb_param-&amp;gt;status = RET_ERROR;
            break;
        }
    }

    NRF_LOG_INFO(&amp;quot;zcl_device_cb status: %hd&amp;quot;, p_device_cb_param-&amp;gt;status);
}

/**@brief Zigbee stack event handler.
 *
 * @param[in]   bufid   Reference to the Zigbee stack buffer used to pass signal.
 */
void zboss_signal_handler(zb_bufid_t bufid)
{
    /* Update network status LED */
    zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED);

    /* No application-specific behavior is required. Call default signal handler. */
    ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));

    if (bufid)
    {
        zb_buf_free(bufid);
    }
}

/**@brief Function for application main entry.
 */
int main(void)
{
    zb_ret_t       zb_err_code;
    zb_ieee_addr_t ieee_addr;

    /* Initialize timer, logging system and GPIOs. */
    timer_init();
    log_init();
    leds_buttons_init();

    /* Set Zigbee stack logging level and traffic dump subsystem. */
    ZB_SET_TRACE_LEVEL(ZIGBEE_TRACE_LEVEL);
    ZB_SET_TRACE_MASK(ZIGBEE_TRACE_MASK);
    ZB_SET_TRAF_DUMP_OFF();

    /* Initialize Zigbee stack. */
    ZB_INIT(&amp;quot;led_bulb&amp;quot;);

    /* Set device address to the value read from FICR registers. */
    zb_osif_get_ieee_eui64(ieee_addr);
    zb_set_long_address(ieee_addr);

    /* Set static long IEEE address. */
    zb_set_network_router_role(IEEE_CHANNEL_MASK);
    zb_set_max_children(MAX_CHILDREN);
    zigbee_erase_persistent_storage(ERASE_PERSISTENT_CONFIG);
    zb_set_keepalive_timeout(ZB_MILLISECONDS_TO_BEACON_INTERVAL(3000));

    /* Initialize application context structure. */
    UNUSED_RETURN_VALUE(ZB_MEMSET(&amp;amp;m_dev_ctx, 0, sizeof(m_dev_ctx)));

    /* Register callback for handling ZCL commands. */
    ZB_ZCL_REGISTER_DEVICE_CB(zcl_device_cb);

    /* Register dimmer switch device context (endpoints). */
    ZB_AF_REGISTER_DEVICE_CTX(&amp;amp;dimmable_light_ctx);

    bulb_clusters_attr_init();
    level_control_set_value(m_dev_ctx.level_control_attr.current_level);

    /** Start Zigbee Stack. */
    zb_err_code = zboss_start_no_autostart();
    ZB_ERROR_CHECK(zb_err_code);

    while(1)
    {
        zboss_main_loop_iteration();
        UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
    }
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;zb_ha_dimmable_light.h:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* ZBOSS Zigbee 3.0
 *
 * Copyright (c) 2012-2018 DSR Corporation, Denver CO, USA.
 * http://www.dsr-zboss.com
 * http://www.dsr-corporation.com
 * All rights reserved.
 *
 *
 * Use in source and binary forms, redistribution in binary form only, with
 * or without modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 2. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 3. This software, with or without modification, must only be used with a Nordic
 *    Semiconductor ASA integrated circuit.
 *
 * 4. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PURPOSE: HA Dimmable Light device definition
*/

#if ! defined ZB_HA_DIMMABLE_LIGHT_H
#define ZB_HA_DIMMABLE_LIGHT_H

#if defined ZB_HA_DEFINE_DEVICE_DIMMABLE_LIGHT || defined DOXYGEN

/** @cond DOXYGEN_HA_SECTION */

/**
 *  @defgroup ZB_HA_DEFINE_DEVICE_DIMMABLE_LIGHT Dimmable Light
 *  @ingroup ZB_HA_DEVICES
 *  @{
    @details
        - @ref ZB_ZCL_BASIC \n
        - @ref ZB_ZCL_IDENTIFY \n
        - @ref ZB_ZCL_SCENES \n
        - @ref ZB_ZCL_GROUPS \n
        - @ref ZB_ZCL_ON_OFF \n
        - @ref ZB_ZCL_LEVEL_CONTROL

*/

/******************* Specific definitions for window covering device **************************/

#define ZB_HA_DEVICE_VER_DIMMABLE_LIGHT 1 /*!&amp;lt; Dimmable light device version */

/** @cond internals_doc */

#define ZB_HA_DIMMABLE_LIGHT_IN_CLUSTER_NUM 7  /*!&amp;lt; Dimmable Light IN (server) clusters number */
#define ZB_HA_DIMMABLE_LIGHT_OUT_CLUSTER_NUM 0 /*!&amp;lt; Dimmable Light OUT (client) clusters number */

/** Dimmable light total (IN+OUT) cluster number */
#define ZB_HA_DIMMABLE_LIGHT_CLUSTER_NUM                                \
  (ZB_HA_DIMMABLE_LIGHT_IN_CLUSTER_NUM +  ZB_HA_DIMMABLE_LIGHT_OUT_CLUSTER_NUM)

/*! Number of attribute for reporting on Dimmable Light device */
#define ZB_HA_DIMMABLE_LIGHT_REPORT_ATTR_COUNT         \
  (ZB_ZCL_ON_OFF_REPORT_ATTR_COUNT + ZB_ZCL_LEVEL_CONTROL_REPORT_ATTR_COUNT + ZB_ZCL_ELECTRICAL_MEASUREMENT_REPORT_ATTR_COUNT)

#define ZB_HA_DIMMABLE_LIGHT_CVC_ATTR_COUNT 1

/** @endcond */

/*!
  @brief Declare cluster list for Dimmable Light device
  @param cluster_list_name - cluster list variable name
  @param basic_attr_list - attribute list for Basic cluster
  @param identify_attr_list - attribute list for Identify cluster
  @param groups_attr_list - attribute list for Groups cluster
  @param scenes_attr_list - attribute list for Scenes cluster
  @param on_off_attr_list - attribute list for On/Off cluster
  @param level_control_attr_list - attribute list for Level Control cluster
  @param el_meas_attr_list - attribute list for Electrical Measurement cluster
 */
#define ZB_HA_DECLARE_DIMMABLE_LIGHT_CLUSTER_LIST(               \
  cluster_list_name,                                             \
  basic_attr_list,                                               \
  identify_attr_list,                                            \
  groups_attr_list,                                              \
  scenes_attr_list,                                              \
  on_off_attr_list,                                              \
  level_control_attr_list,                                       \
  el_meas_attr_list)                                             \
  zb_zcl_cluster_desc_t cluster_list_name[] =                    \
  {                                                              \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_IDENTIFY,                                \
      ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),      \
      (identify_attr_list),                                      \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    ),                                                           \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_BASIC,                                   \
      ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),         \
      (basic_attr_list),                                         \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    ),                                                           \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_SCENES,                                  \
      ZB_ZCL_ARRAY_SIZE(scenes_attr_list, zb_zcl_attr_t),        \
      (scenes_attr_list),                                        \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    ),                                                           \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_GROUPS,                                  \
      ZB_ZCL_ARRAY_SIZE(groups_attr_list, zb_zcl_attr_t),        \
      (groups_attr_list),                                        \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    ),                                                           \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_ON_OFF,                                  \
      ZB_ZCL_ARRAY_SIZE(on_off_attr_list, zb_zcl_attr_t),        \
      (on_off_attr_list),                                        \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    ),                                                           \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,                           \
      ZB_ZCL_ARRAY_SIZE(level_control_attr_list, zb_zcl_attr_t), \
      (level_control_attr_list),                                 \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    ),                                                           \
    ZB_ZCL_CLUSTER_DESC(                                         \
      ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT,                  \
      ZB_ZCL_ARRAY_SIZE(el_meas_attr_list, zb_zcl_attr_t),       \
      (el_meas_attr_list),                                       \
      ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
      ZB_ZCL_MANUF_CODE_INVALID                                  \
    )                                                            \
  }


/*! @cond internals_doc */
/*!
  @brief Declare simple descriptor for Dimmable Light device
  @param ep_name - endpoint variable name
  @param ep_id - endpoint ID
  @param in_clust_num - number of supported input clusters
  @param out_clust_num - number of supported output clusters
*/
#define ZB_ZCL_DECLARE_HA_DIMMABLE_LIGHT_SIMPLE_DESC(ep_name, ep_id, in_clust_num, out_clust_num) \
  ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                                            \
  ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name =                     \
  {                                                                                               \
    ep_id,                                                                                        \
    ZB_AF_HA_PROFILE_ID,                                                                          \
    ZB_HA_DIMMABLE_LIGHT_DEVICE_ID,                                                               \
    ZB_HA_DEVICE_VER_DIMMABLE_LIGHT,                                                              \
    0,                                                                                            \
    in_clust_num,                                                                                 \
    out_clust_num,                                                                                \
    {                                                                                             \
      ZB_ZCL_CLUSTER_ID_BASIC,                                                                    \
      ZB_ZCL_CLUSTER_ID_IDENTIFY,                                                                 \
	    ZB_ZCL_CLUSTER_ID_SCENES,                                                                   \
      ZB_ZCL_CLUSTER_ID_GROUPS,                                                                   \
      ZB_ZCL_CLUSTER_ID_ON_OFF,                                                                   \
      ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,                                                            \
      ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT,                                                   \
    }                                                                                             \
  }

/*! @endcond */

/*!
  @brief Declare endpoint for Dimmable Light device
  @param ep_name - endpoint variable name
  @param ep_id - endpoint ID
  @param cluster_list - endpoint cluster list
 */
/* TODO: add scenes? */
#define ZB_HA_DECLARE_DIMMABLE_LIGHT_EP(ep_name, ep_id, cluster_list)           \
  ZB_ZCL_DECLARE_HA_DIMMABLE_LIGHT_SIMPLE_DESC(ep_name, ep_id,                  \
    ZB_HA_DIMMABLE_LIGHT_IN_CLUSTER_NUM, ZB_HA_DIMMABLE_LIGHT_OUT_CLUSTER_NUM); \
  ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name,          \
                                     ZB_HA_DIMMABLE_LIGHT_REPORT_ATTR_COUNT);   \
  ZBOSS_DEVICE_DECLARE_LEVEL_CONTROL_CTX(cvc_alarm_info## device_ctx_name,      \
                                         ZB_HA_DIMMABLE_LIGHT_CVC_ATTR_COUNT);  \
  ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, ZB_AF_HA_PROFILE_ID,              \
    0,                                                                          \
    NULL,                                                                       \
    ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), cluster_list,       \
                          (zb_af_simple_desc_1_1_t*)&amp;amp;simple_desc_##ep_name,     \
                          ZB_HA_DIMMABLE_LIGHT_REPORT_ATTR_COUNT,               \
                          reporting_info## device_ctx_name,                     \
                          ZB_HA_DIMMABLE_LIGHT_CVC_ATTR_COUNT,                  \
                          cvc_alarm_info## device_ctx_name)

/**
  @brief Declare application&amp;#39;s device context for Dimmable Light device
  @param device_ctx - device context variable
  @param ep_name - endpoint variable name
*/
#define ZB_HA_DECLARE_DIMMABLE_LIGHT_CTX(device_ctx, ep_name)                                                    \
  ZBOSS_DECLARE_DEVICE_CTX_1_EP(device_ctx, ep_name)

/*! @} */

/** @endcond */ /* DOXYGEN_HA_SECTION */

#endif /* ZB_HA_DEFINE_DEVICE_DIMMABLE_LIGHT */

#endif /* ! defined ZB_HA_DIMMABLE_LIGHT_H */
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee Dimmable light bulb with electrical measurement</title><link>https://devzone.nordicsemi.com/thread/265361?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 14:12:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51b72c86-16f9-4f73-8830-1285dff99449</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Jakub,&lt;/p&gt;
&lt;p&gt;From your implementation, it looks like you are trying to add the measurement cluster to your light bulb cluster. Is that the intention?&lt;/p&gt;
&lt;p&gt;If so, you need to add el_meas_attr_list to your ZB_HA_DECLARE_DIMMABLE_LIGHT_CLUSTER_LIST. As it is now, you never use&amp;nbsp;el_meas_attr_list for anything, and then you try to add the measurement cluster in your bulb_clusters_attr_init(), when it has never been declared anywhere earlier.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Exactly why the application is not working, I don&amp;#39;t know. IT stops after:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ZB_ZCL_SET_ATTRIBUTE(HA_DIMMABLE_LIGHT_ENDPOINT,
                         ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT,
                         ZB_ZCL_CLUSTER_SERVER_ROLE,
                         ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID,
                         (zb_uint8_t *)&amp;amp;m_dev_ctx.el_meas_attr.dc_power,
                         ZB_FALSE);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Probably because this cluster is not initialized with any cluster called ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT. Maybe it is a memory corruption issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Try to add the measurement cluster to the ZB_HA_DECLARE_DIMMABLE_LIGHT_CLUSTER_LIST, and see if that helps.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>