Hey there,
I know it’s probably going to be something very simple, I am out of ideas to what it could be.I’ve already made the schedule and used the code from the Original post and tried to work out what the errors by referring to this post about errors. however I’m at a loss for what is wrong with it as it is still not working.
Sorry if I haven’t done something that is very obvious. Please let me know what it is. Could it be something that I have not made like the service in my configuration.yaml file.
Thank you.
Home Assistant 2022.10.5 (Container)
The goal of my automation is to be able to have the plug turn on and off depending on the schedule helper in the home assistant.
My Automation code
alias: example
description: ""
trigger:
- platform: state
entity_id:
- schedule.hallway_light_schedule
condition:
- condition: template
value_template: "{{ trigger.to_state.state in ['on', 'off'] }}"
action:
- service: 'light.turn_{{ trigger.to_state.state }}'
target:
entity_id: light.hall_light_plug_light
Changes that I made from the original code are
- from schedule.your_schedule to schedule.hallway_light_schedule|
- from light.your_light to light.hall_light_plug_light|
- from ‘light.turn_{{ trigger.to_state.state }}’ to light.turn_{{ trigger.to_state.state }}
(I’ve tried putting back the ’ and then run the automation it does not keep them in, also I tried “” and the same thing happens)
I get these errors when I run this automation from the logs screen
Errors
Logger: homeassistant.helpers.template
Source: helpers/template.py:420
First occurred: 18:40:59 (8 occurrences)
Last logged: 19:49:46
Template variable error: 'dict object' has no attribute 'to_state' when rendering 'light.turn_{{ trigger.to_state.state }}'
Template variable error: 'trigger' is undefined when rendering 'light.turn_{{ trigger.to_state.state }}'
Logger: homeassistant.components.automation.example
Source: helpers/script.py:409
Integration: Automation (documentation, issues)
First occurred: 18:40:59 (7 occurrences)
Last logged: 19:49:46
example: Error executing script. Error for call_service at pos 1: Error rendering service name template: UndefinedError: 'dict object' has no attribute 'to_state'
Logger: homeassistant.components.automation.example
Source: components/automation/__init__.py:253
Integration: Automation (documentation, issues)
First occurred: 18:40:59 (7 occurrences)
Last logged: 19:49:46
Error while executing automation automation.example: Error rendering service name template: UndefinedError: 'dict object' has no attribute 'to_state'
The Hall Light Plug Light entity State attributes
supported_color_modes:
- onoff
off_with_transition: false
off_brightness: null
friendly_name: Hall Light Plug Light
supported_features: 8