1st post so please be gentle. I am just starting to get my head round hassio and have been able to make a mqtt switch which is working from the dashboard so i can switch it on and off manually no problems. What I want to do is set up a start stop timer to automate this function for an aquarium control system, I have been trawling looking for a simple set up but everyone I try fails the config check so this is my switch in the configuration.yaml and i need it to switch on at 8am and switch of at 3pm.
- alias: Turn on Aquarium at 08:00
initial_state: 'on'
trigger:
- platform: time
at: '08:00:00'
action:
# Turn Power On
- service: homeassistant.turn_on
entity_id: switch.tank
- alias: Turn off Aquarium at 15:00
initial_state: 'on'
trigger:
- platform: time
at: '15:00:00'
action:
# Turn Power Off
- service: homeassistant.turn_off
entity_id: switch.tank
Thanks for that I have pasted it in the Automations.yaml file and the little green tick is showing all ok in the file when I save and go to check the config I get this.
action: [source /config/automations.yaml:9
] - entity_id: switch.tank
service: homeassistant.turn_on
alias: Turn on Aquarium at 08:00
initial_state: on
trigger: [source /config/automations.yaml:5]
platform: time at: 08:00:00
action: [source /config/automations.yaml:19]
entity_id: switch.tank
service: homeassistant.turn_off
alias: Turn off Aquarium at 15:00
initial_state: on
trigger: [source /config/automations.yaml:15]
platform: time at: 15:00:00
Successful config (partial)
automation:
here is the automation.yaml
- alias: Turn on Aquarium at 08:00
initial_state: 'on'
trigger:
- platform: time
at: '08:00:00'
action:
# Turn Power On
- service: homeassistant.turn_on
entity_id: switch.tank
- alias: Turn off Aquarium at 15:00
initial_state: 'on'
trigger:
- platform: time
at: '15:00:00'
action:
# Turn Power Off
- service: homeassistant.turn_off
entity_id: switch.tank
and here is the configuration.yaml
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 55.8833
longitude: -3.5333
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 114
# metric for Metric, imperial for Imperial
unit_system: metric
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Europe/London
# Customization file
customize: !include customize.yaml
# Show links to resources in log and frontend
# introduction:
# Enables the frontend
frontend:
mqtt:
broker: core-mosquitto
username: #######
password: #######
switch:
switch light:
- platform: mqtt
name: "tank"
state_topic: "ha/tank"
command_topic: "ha/tank"
qos: 0
payload_on: "ON"
payload_off: "OFF"
optimistic: false
retain: true
panel_iframe:
configurator:
title: Configurator
icon: mdi:wrench
url: http://192.168.0.64:3218
# Enables configuration UI
config:
http:
# Secrets are defined in the file secrets.yaml
# api_password: !secret http_password
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# base_url: example.duckdns.org:8123
# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
# Optional, allows Home Assistant developers to focus on popular components.
# include_used_components: true
# Discover some devices automatically
discovery:
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Enables support for tracking state changes over time
history:
# Tracked history is kept for 10 days
recorder:
purge_keep_days: 10
# View all events in a logbook
logbook:
# Enables a map showing the location of tracked devices
map:
# Track the sun
sun:
# Weather prediction
sensor:
- platform: yr
# Text to speech
tts:
- platform: google
# Cloud
cloud:
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
These were all the sorts of errors I got trying other examples by other people. If anyone can shed some light I would appreciate it as finding this Home automation setup really confusing and not very user friendly.
- alias: Turn on Aquarium at 08:00
initial_state: 'on'
trigger:
- platform: time
at: '08:00:00'
action:
# Turn Power On
- service: homeassistant.turn_on
entity_id: switch.tank
- alias: Turn off Aquarium at 15:00
initial_state: 'on'
trigger:
- platform: time
at: '15:00:00'
action:
# Turn Power Off
- service: homeassistant.turn_off
entity_id: switch.tank
Try like this, I removed one space from each line.
Maybe on the long run if you start having a lot of automations you’re automation.yaml will be very full.
Instead of automation: !include automations.yaml I have automation: !include_dir_list Automations and created a folder called Automations and I save every automation per file.
exemple: turn_on_aquarium_at_8.yaml
alias: Turn on Aquarium at 08:00
initial_state: 'on'
trigger:
- platform: time
at: '08:00:00'
action:
# Turn Power On
- service: homeassistant.turn_on
entity_id: switch.tank
example: turn_off_aquarium_at_15.yaml
alias: Turn off Aquarium at 15:00
initial_state: 'on'
trigger:
- platform: time
at: '15:00:00'
action:
# Turn Power Off
- service: homeassistant.turn_off
entity_id: switch.tank
Thanks for all your help so far go it working the problem was self inflicted as I had been trying various setups from the web I was coping the code and most had automation: at the top and I copied this in the file and this was causing the errors. Removed it and using the code supplied at the top of this thread and got the switch working.
Thanks again and probably will be back looking for more help soon.