Hello there,
I’m sorry if this is really repeated but can’t really find my answer anywhere.
I’m trying to change a state of a entity that i manage to create to use as a “variable”, so basically a fake entity to use as a future condition on my automations.
I can do it on the api and it works.
Can i change the value in automation, for example, i open my cover as sunrise, the action is open cover and i want also to add change state of entity to 1!
Hope somebody can help me.
Thanks
What kind of entity are you trying to use as a variable?
There are some that are set up to be used for that, e.g. input_number, input_datetime, input_boolean, etc.
Others, like sensors, are not supposed to be used for that because … well … they are supposed to ‘sense’ the value/state from an entity, e.g. yesterday’s precipitation at your location.
And then there are some that you can ‘trick’ into setting a state like I did for this one via MQTT when I had this issue:
- alias: Downstairs Light Toggle
trigger:
- platform: state
entity_id: sensor.0x00158d00023e5a81_click
to: 'double'
action:
- service: switch.toggle
entity_id: switch.etekcity_0315_1
- service: mqtt.publish
data_template:
topic: 'zigbee2mqtt/XA_Btn_01'
payload: >-
{
"click": ""
}
2 Likes
Well, thanks for answer.
It is a simple entity. I basically introduced one random name in the development api as auto.cover. The ideia is, when my cover opens at sunrise, it changes value to 1 and when it closes at sunset to 0!
So after i make some new automations with that info as condition, for example when the uv protection is off, the cover is closed and the auto.cover is 0 it stays closed. But if auto.cover is 1 it opens again!
I try this manually and it works, just don’t know if there is any simple way to change this state in the primary automation.
Don’t know if I’m explaining myself correctly. Or making a lot of mistakes.
1 Like
I’d introduce an input_boolean that
- normally has its state changed at sunset/sunrise,
- which then triggers the automation (instead of sunset/sunrise directly)
and
- can be manipulated in an automation by changing its state programmatically (see here for details).
1 Like