Skip to content

Instantly share code, notes, and snippets.

Last active February 10, 2023 15:33
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Home Assistant script to set an entity's state, used with the IKEA Tradfri remote control.
if 'entity_id' not in data:
logger.warning("===== entity_id is required if you want to set something.")
data = data.copy()
inputEntity = data.pop('entity_id')
inputStateObject = hass.states.get(inputEntity)
if inputStateObject:
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()
inputState = 'unknown'
inputAttributesObject = {}
if 'state' in data:
inputState = data.pop('state')
logger.debug("===== new attrs: {}".format(data))
hass.states.set(inputEntity, inputState, inputAttributesObject)
Copy link

Yes. I have tested under dev tool. It behave same.
And just checked logs, no any logs shows about this.
Current log level set to debug.
Please advise how should I troubleshoot this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment