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

Ignore Alexa On/ Off command

Hello,

I am developing one Zigbee based product for that I am using nRF52840 and light_bulb examples and modified as per my requirement.

Till now everything successfully working. Able to control my functions.

One thing we are adding is using a GPIO switch On/Off the LED. So in this case what I want is if the On command from GPIO input then ignore the Alexa On/Off commands and keep the Alexa Dimming operation working.

I am using on_off_set_value() functions to Off and level_control_set_value(m_dev_ctx.level_control_attr.current_level) to On.

Let me know how to achieve this.

And also while dimming (Increment/Decrement) using GPIO pin long press I am using this,

- m_dev_ctx.level_control_attr.current_level = m_dev_ctx.level_control_attr.current_level + 13;

- level_control_set_value(m_dev_ctx.level_control_attr.current_level);

It is working perfectly and reflecting on the Alexa app now but what is happing is I can see step increment instead of gradual increase/decrease and reflection is a bit slow. 

So can you please help me with how to handle both cases and reflection makes fast like a command from Alexa device.

Thanks and Regards

Rohit R

  • Hello,

    Perhaps you can just use the callbacks from the events that Alexa generates, and just update the physical peripherals with what you want to, and skip the rest?

    E.g. if the callback says: Dim to 50% and turn off, and you don't want to turn it off, just set the brightness to 50%?

    Best regards,

    Edvin

  • Hi Edvin,

    E.g. if the callback says: Dim to 50% and turn off, and you don't want to turn it off, just set the brightness to 50%?

    - Yes, same but when the ON/OFF command from GPIO interrupts on short press I am using on_off_set_value() functions and making my brightness variable zero. I think because of that my next command from the GPIO button interrupts not working.

    - why used this on_off_set_value () function is, I want to reflect the status on Alexa App whenever there is a command from the GPIO pin. means for every increment/ decrement and On/Off command, I wanted to reflect the status on the Alexa app like how it does for when a command from Alexa echo device.

    - For that I used level_control_set_value(m_dev_ctx.level_control_attr.current_level) and on_off_set_value () function. But it is showing steps increment/decrement but not gradual means softly.

    Thanks and Regards

    Rohit R

  • Rohit Rajapure said:
    Yes, same but when the ON/OFF command from GPIO interrupts on short press I am using on_off_set_value() functions and making my brightness variable zero

     Yes. You can see that from the implementation:

    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);
        }
    }

    light_bulb_set_brightness(0U), will set the brightness. Try to comment out that. You need to figure out what application logic you want to use (everything in your main.c file). Just make sure that you keep the ZB_ZFL_SET_ATTRIBUTE(), so that the device that sends the on/off commands (the alexa) believes that the light bulb is behaving according to the zigbee specification. If not, I believe things will start to behave weirdly.

    What you actually do on your physical GPIOs, is up to you.

Related