This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zigbee light_bulb turns full On(100%) instead of setting to 10% level

Hello All,

I am developing a light control device using Zigbee and Alexa. I am using an nRF52840 device and SDK nRF5_SDK_for_Thread_and_Zigbee_v3.0.0_d310e71.

For my development, I have referred to light_bulb code as per nordic engineer suggestion and made the respected changes to communicate with Alexa.

Till now everything is working perfectly fine without any issue even On dev-kit and my custom hardware so while testing corner cases on my hardware.

I came to know that if I send the "Alexa set 0 percent" command from the Alexa device it turns OFF correctly. But if I give "Alexa Turn ON" then it takes 100 percent (100%) not 10% or 20% which was my previous set level before setting to 0%.

But If I use the "Alexa Turn ON" and "Alexa Turn OFF" command then I get the expected result means example. If I set the level to 20% and then gave the OFF command it turns OFF and If I say "Alexa turn ON" then it turns ON to the set level which is 20%.

Only, If give "Alexa set 0 percentage" and "Alexa Turn ON" I facing this 100% ON instead of the previous level.

This same case happing in SDK's light_bulb code.

So please let me know the reason behind this? And also can we change as per our requirement? If yes, then share the steps so that we can keep command execution identical in all cases.

Thanks and Regards

Rohit R

Parents
  • Hello,

    Have you tried to sniff the connection? I suspect that it is the Alexa that sets the brightness to 100% when it is set to 0, and then toggled on. At least looking at the implementation of the light bulb it looks like it doesn't do as you describe if it receives an "on" and the brightness is set to 0:

    (new level is the previous brightness)

    /**@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("Set level value: %i", 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 *)&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,
                                 &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,
                                 &value,                        
                                 ZB_FALSE);
        }
    
        light_bulb_set_brightness(new_level);
    }

    Which is called from the on_off_set_value():

    /**@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("Set ON/OFF value: %i", 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 *)&on,                        
                             ZB_FALSE);
    
        if (on)
        {
            level_control_set_value(m_dev_ctx.level_control_attr.current_level);
        }
        else
        {
            light_bulb_set_brightness(0U);
        }
    }

    Have you either tried to sniff the network or see what the alexa does with other Zigbee light bulbs, such as an IKEA lightbulb (TRÅDFRI) or a Philips Hue?

    BR,

    Edvin

  • Hi Edvin,

    Ya, even I tried to backtrace what is the problem.

    As you said these above 2 function works when On/Off command sends. But strange why it tacking when we send "Alexa turn ON" after setting "Alexa set 0%" instead of previous values.

    Have you either tried to sniff the network or see what the alexa does with other Zigbee light bulbs, such as an IKEA lightbulb (TRÅDFRI) or a Philips Hue?

    - I do not have these devices and for sniffing I need some plug-in devices but due to work from home, I do not have many devices. Only Dev-kit is with me and I am working on it.

    We need to check the reason for this.

    Let me know if you get any lead points. I will also check with the suggested device to manage and test.

    Thanks and Regards

    Rohit R

  • The log backend in the Zigbee examples is described in sdk_config.h:

    // <o> NRF_LOG_BACKEND_UART_BAUDRATE  - Default Baudrate
     
    // <323584=> 1200 baud 
    // <643072=> 2400 baud 
    // <1290240=> 4800 baud 
    // <2576384=> 9600 baud 
    // <3862528=> 14400 baud 
    // <5152768=> 19200 baud 
    // <7716864=> 28800 baud 
    // <10289152=> 38400 baud 
    // <15400960=> 57600 baud 
    // <20615168=> 76800 baud 
    // <30801920=> 115200 baud 
    // <61865984=> 230400 baud 
    // <67108864=> 250000 baud 
    // <121634816=> 460800 baud 
    // <251658240=> 921600 baud 
    // <268435456=> 1000000 baud 
    
    #ifndef NRF_LOG_BACKEND_UART_BAUDRATE
    #define NRF_LOG_BACKEND_UART_BAUDRATE 268435456
    #endif

    So by default it uses baudrate: 1000000, buy you can change it to 115200 by setting the value "30801920".

    You can do a soft reset using the function NVIC_SystemReset(); If you want to do this on a pin interrupt, you need to set up a pin interrupt for the pin you want to use.

    In the light bulb example, there is a function called buttons_handler(). Try adding this to the event handler:

            case BSP_EVENT_KEY_1:
                NRF_LOG_INFO("Button 2 pressed");
                break;

    And if you want to reset based on that button press, then you can add NVIC_SystemReset(); to that event. Note that the log probably won't finish printing before the reset.

    BR,
    Edvin

  • Hi Edvin,

    Thank you so much for your response,

    I will make the baud rate changes and test the same.

    Here is my log file. dim 0% and turn ON command,

    <info> app: Set level value: 255
    <warning> app: Production config is not present or invalid
    <info> app: Joined network successfully
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 255
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 26
    <info> app: Set level value: 26
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 254
    <info> app: Set level value: 254
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 254
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 52
    <info> app: Set level value: 52
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 52
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 0
    <info> app: Set ON/OFF value: 0
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 0
    <info> app: on/off attribute setting to 1
    <info> app: Set ON/OFF value: 1
    <info> app: Set level value: 1
    <info> app: zcl_device_cb status: 0
    <info> app: zcl_device_cb id 7
    <info> app: Level control setting to 254
    <info> app: Set level value: 254
    <info> app: zcl_device_cb status: 0
    

    You can do a soft reset using the function NVIC_SystemReset(); If you want to do this on a pin interrupt, you need to set up a pin interrupt for the pin you want to use.

    - Okay, I will do the changes as per your suggestion and test using light_bulb.

    And thank you so much for these soft reset feature details. I will get back to you with the testing.

    - I am able to reset the device after pin interrupt.

    My requirement for testing is,

    - Read GPIO interrupt and after 5sec soft reset the device (NVIC_SystemReset()). which working after making changes as per your suggestion.

    - along with reset one more thing I need to perform is Erase Bonding information of Alexa device from my hard ware device. As per my study I need to just make changes in below ling,

    zigbee_erase_persistent_storage(ZB_TRUE);  //Erase Alexa hardware device bonding information

    Set TRUE, it will perform the erase but I tried the same it is not working. Still device connected to Alexa.

    Let me know if I am doing wrong in erasing.

    Once again thank you so much Slight smile

    Thanks and Regards

    Rohit R

  • Based on your log, it seems that it receives an event ZB_ZCL_LEVEL_CONTROL_SET_VALUE_CB_ID, with the level 254. 

     

    Rohit Rajapure said:
    Set TRUE, it will perform the erase but I tried the same it is not working. Still device connected to Alexa.

     Is it? My experience was that it wasn't, but perhaps it depends on the device. What I tested was a doorlock (I no longer have access to that Alexa, so I can't test). 

    Does the Alexa still remember the device even if you erase the flash on the nRF and re-program it?

  • Hi Edvin,

    Based on your log, it seems that it receives an event ZB_ZCL_LEVEL_CONTROL_SET_VALUE_CB_ID, with the level 254. 

    - yes, it is a 0xfe (254) value.

    - Is there any possibility to change as per requirement?

    Is it? My experience was that it wasn't, but perhaps it depends on the device. What I tested was a doorlock (I no longer have access to that Alexa, so I can't test). 

    Does the Alexa still remember the device even if you erase the flash on the nRF and re-program it?

    - I have solved this, now can do interrupt soft reset and as well as erase bonding info.

    - Thank you for this urgent help and details. We can make hardware as required. In case of anything, I will get back to you on this.

    Thank you so much for the quick response on this Slight smile.

    Regards,

    Rohit R

  • Rohit Rajapure said:
    - Is there any possibility to change as per requirement?

    What do you mean? Any way to change what the Alexa decides to do? I wouldn't know how to do that, at least.

    Rohit Rajapure said:

    - I have solved this, now can do interrupt soft reset and as well as erase bonding info.

    - Thank you for this urgent help and details. We can make hardware as required. In case of anything, I will get back to you on this.

     Glad to hear that it worked out. As for the alexa part, I am not sure how you would modify it. I guess you can physically not perform the PWM change, but then you would still have to report to the alexa over Zigbee that you did. If not the alexa would start to act up.

    I believe the light bulb just needs to obey the orders that it receives. If not, it would behave differently from all other light bulbs in the network. Don't you agree?

    BR,

    Edvin

Reply
  • Rohit Rajapure said:
    - Is there any possibility to change as per requirement?

    What do you mean? Any way to change what the Alexa decides to do? I wouldn't know how to do that, at least.

    Rohit Rajapure said:

    - I have solved this, now can do interrupt soft reset and as well as erase bonding info.

    - Thank you for this urgent help and details. We can make hardware as required. In case of anything, I will get back to you on this.

     Glad to hear that it worked out. As for the alexa part, I am not sure how you would modify it. I guess you can physically not perform the PWM change, but then you would still have to report to the alexa over Zigbee that you did. If not the alexa would start to act up.

    I believe the light bulb just needs to obey the orders that it receives. If not, it would behave differently from all other light bulbs in the network. Don't you agree?

    BR,

    Edvin

Children
  • Hi Edvin,

    What do you mean? Any way to change what the Alexa decides to do? I wouldn't know how to do that, at least.

    - Okay,

    Glad to hear that it worked out.

    - Thank you for the help Slight smile

    As for the alexa part, I am not sure how you would modify it. I guess you can physically not perform the PWM change, but then you would still have to report to the alexa over Zigbee that you did. If not the alexa would start to act up.

    - Yes, I reported to the forum but still no replay

    I believe the light bulb just needs to obey the orders that it receives. If not, it would behave differently from all other light bulbs in the network. Don't you agree?

    - Yes, I also believe the same. The device should perform orders that it receives.

    - If I get any update from the Alexa amazon team then I will get back to you with their feedback.

    Thank you

    Regards,

    Rohit R

Related