The variable trigger
has no value in the Template editor, unless you assign one to it.
You can use Trigger IDs to simplify your automation, and you need to place the entity ID under target
or data
(this is the source of the Message malformed
error):
- alias: "Control Master Window Right Socket based on Blind Battery"
trigger:
- platform: numeric_state
entity_id: sensor.blind_master_battery
below: 25
id: 'on'
- platform: numeric_state
entity_id: sensor.blind_master_battery
above: 80
id: 'off'
condition: []
action:
- service: switch.turn_{{ trigger.id }}
target:
entity_id: switch.master_sockets_window_right
FWIW, ChatGPT and other LLM are particularly bad at Home Assistant. They hallucinate answers the majority of the time. And their hallucinations are often plausible-looking, making them difficult to identify without significant HA experience.