I’m pretty new to HA - coming from Symcon and currently testing several things, if I really can replace my current system. So, I’m not new to home automation at all.
Currently I’m trying to figure out how to solve following topic:
I’ve a shelly switch where my 3d printer and an octoprint raspi is connected.
Now I want to create a new switch and a state string, which should be shown in an dashboard.
when I turn on the new switch:
Shelly switch should be turned on
state string should be “booting”
When one of the Octoprint sensors going to any state but “Unavailable”
state string switching to “on”
when I then turn off the new switch:
trigger Octoprint shutdown
state string should then be “shutting down”
after 60 seconds
state string should switch to “off”
especially the state string drives me crazy how to implement it. I tried several things, i.e. template helper select. - all others may be a topic of automation, but I didn’t get to that point right now.
A switch can only be in an on or an off state, so it can’t show four separate states.
I’d probably use an input_text helper for that, display its state and ‘fill’ its state from an automation that works with trigger ids, similar to this - the on and of sequence can be triggered in the dashboard with a tap action on the helper or an additional button:
alias: Set Garage Door Detailed Status
description: ""
mode: single
triggers:
- entity_id:
- binary_sensor.xa_ds_gd_contact
from: "off"
to: "on"
id: Opening
trigger: state
- entity_id:
- binary_sensor.xa_ds_gd_contact
from: "on"
to: "off"
id: Closed
trigger: state
- entity_id:
- cover.garage_door
from: closed
to: open
id: Open
trigger: state
- entity_id:
- cover.garage_door
from: open
to: closed
id: Closing
trigger: state
conditions: []
actions:
- data:
value: "{{ (trigger.id) }}"
target:
entity_id: input_text.garage_door_status
action: input_text.set_value
Trigger 1: when the state of the Shelly changes to ‘on’, use the id ‘booting’ to set the input_text.set_value
Trigger 2: when the state any of the Octoprint sensors chages 'from: unavailable, use the id ‘on’
Trigger 3: when the new switch changes to ‘off’, use the id ‘shutdown’ and create another automation that triggers when the state of the input_text changes to ‘shutdown’ and actually carries out the Octoprint shutdown
Trigger 4: when the new switch has been in the state ‘shutdown’ for 60 seconds, use the id ‘off’
Note:
This can probably also be achieved in a template trigger sensor in the configuration.yaml directly rather than with the automation, but that’s how I would address it.