I have a couple of MS7’s that occasionally get stuck on motion detected. I’m trying to use the set value command to clear the motion detection, but I can’t get it to work.
It’s been my experience that the device isn’t the issue with hung motion state, but the software. Likely caused by missed updates from Z-wave. At that point the device and the software are out of sync. You would be better off changing the entity state in Developer Tools to restore the sync.
Note that this is a symptom of a Z-wave communications problem. If you use Z-wave-JS-UI I would suggest checking the Z-wave device health.
I can’t change the entity state as it’s a binary sensor. I found a python script that can change the state of a binary sensor, but it doesn’t actually work as even when I force it to the same state, it doesn’t actually match the state that is set by Z-Wave JS.
If you select device as your trigger then select your sensor from the device list you should see an option called press yourdevicename idle motion sensor.
Developer tools can change the state of any entity AFAIK. I just changed my Entrance Motion from off to on and back to off without issue. Note that I’m not saying the device is changing state, just the entity.
I finally figured it out with the python script. You have to set the state in lower case (on or off) then it works. If you use capitals (ON or OFF), then it doesn’t work.
#==================================================================================================
# python_scripts/set_state.py
#==================================================================================================
#--------------------------------------------------------------------------------------------------
# Set the state or other attributes for the entity specified in the Automation Action
#--------------------------------------------------------------------------------------------------
inputEntity = data.get('entity_id')
if inputEntity is None:
logger.warning("===== entity_id is required if you want to set something.")
else:
inputStateObject = hass.states.get(inputEntity)
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()
for item in data:
newAttribute = data.get(item)
logger.debug("===== item = {0}; value = {1}".format(item,newAttribute))
if item == 'entity_id':
continue # already handled
elif item == 'state':
inputState = newAttribute
else:
inputAttributesObject[item] = newAttribute
hass.states.set(inputEntity, inputState, inputAttributesObject)
Developer tools is a manual action, but as you’ve found the python script can be automated. As I said earlier, I would treat this as a short-term band aid and work to fix the underlying problem by addressing the Z-wave communications issue that causes this.