I have read HA instructions, read thru several threads herein, and got some great guidance from u/Didgeridrew, however, I’m still stuck on creating a couple seemingly simple template sensors.
I wish to set pc1_session_state either ‘Locked’ or ‘Unlocked’, based on the state of ‘sensor.mqtt_sessionstate’. I already have an Automation checking for ‘sensor.mqtt_sessionstate’. Problem is, the Retain Flag does not work on HA reboot. So, I want to set another sensor once there is a change.
I would like to set a sensor based on Sleep state or not. Unlike the above ex, I’m not tracking an existing sensor. I have a Sleep Script and a Wake Script, looking to set ‘sleep’ or ‘wake’ respectively when executing these scripts. Reason… I want to use these as a variable in Conditions for other Automations, scripts, ie. prevent lights from coming on at Sunrise until I’m actually awake. Thoughts on this?
I realized, this still is not working… I’m still getting Unknown for my pc1_session_state sensor.
I think I needed to reboot HA one more time, as it seems to be working now.
it’s not required. Subscribe to your custom event, fire the event and look at the returned data, then you’ll see what trigger.event.data.state is. Keep in mind, that you’ll need to understand trigger templates, specifically event.
As Petro said it’s not. The custom event type can be whatever slug you want, I tend to start mine with custom_ just to make search easy. You just need to make sure the event type raised and the type consumed match exactly.
Thought I would come back to this and at least make your suggestions work… This is what I came up with that works. As for the previous error I was getting… I had not removed the comma’s.