Check light status before send command?

I’m mostly using NR to do the automation. Quick question for when trying to turn on/off light, do you usually check its status when sending command? Currently I first check if the light status is on, then sends the turn off command. Is this extra step necessary? Or it’s better just send turn off command without checking? What’s the best practice? Thanks.

It is better to send the command directly than to check the state. If the ultimate objective is to turn the light on or off and it doesn’t depend on the current status of the entity.

1 Like

Thanks for the response.

I have a motion sensor setup so if there is motion and time between sunset and sunrise, it will turn on the light (zigbee light setup in zigbee2mqtt). If the motion is off, then it will turn off the light.

For the motion off event, I didn’t set the time period checking, so if the light is manually turned on (such as cloudy day), it can be turned off by motion off.

By not checking the current state of light and just send turn off service command when motion is off, I saw a lot of events in the zigbee2mqtt log. Not sure if this creates unnecessary extra load.

I check the status before sending the command personally, not sure if it actually does make a difference but the way i look at it is it reduces the amount of traffic on the MQTT broker, i have Aqara motion sensors dotted about and without HASS / Nodered their just dumb sensors On/Off all day, so i have it check before sending the command as even in the day when the lights are not on because the criteria isn’t met just walking round the house in the day can trigger multiple sensor to “on” then it stops there but when it returns to "off " thats sending a message to maybe 9 light bulbs depending where i walk for no reason i just think its unnecessary thats my way of thinking anyway

1 Like