Automation trigger doesn't work

Hello everybody

I’ve been using HA for a week now and this is my first time on the board. I have a problem configuring the automation part correctly. I’ve copied below conf from these forums and they’ve got it working. Somehow I get an error message (included below).

My system is using google calendar to schedule sauna heating cycles. Everything else except automation triggering the action part works.

Process flow

  1. Google calendar event (calendar.sauna)
  2. sensor (works)
    3. automation trigger (doesn’t work) :slightly_frowning_face:
  3. automation action (works by triggering manually)
  4. switch relay button over mqtt topic
  5. arduino esp8266 board subscribed to mqtt topic
  6. esp8266 controls physical relay (Wemos D1 mini)

Also working: temperature and humidity sensors. So far, HA is the best system I’ve tried by far: fast & reliable. A bit finicky in configuring.

This system is running on pine64, OS: armbian 3.10.107-pine64 arm64/aarch64 ubuntu 16.04 based and HA version is 0.58.1 on python virtual env (version 8).
configuration.yaml https://pastebin.com/Z85YDV4a

While debugging I use the console to start HA. Normally, I’d use systemd to for starting
Error message

    (homeassistant) homeassistant@pine64:~$ hass
Config directory: /home/homeassistant/.homeassistant
2017-12-04 12:16:43 ERROR (Thread-2) [homeassistant.util.yaml] mapping values are not allowed here
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 96, column 16
2017-12-04 12:16:43 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: mapping values are not allowed here
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 96, column 16

I’ve also tried about 50 different ways copied directly from various documentation sources. Nothing seems to work.

Could somebody point me in the right direction?
Any help would be greatly appreciated.

That’s most likely a formatting problem, check that the number of space is correct in your config.

And check this:


So you can post your config with formatting and we can check it.

Using pastebin now

It tells you in the error message exactly where the formatting error is…

line 96, column 16

condition: state
      entity_id: states.calendar.sauna
      state: 'on'

Should be

condition:
  condition: state
  entity_id: states.calendar.sauna
  state: 'on'

I see… it needs double the condition. but the errors do persist

automation part from configuration.yaml now is:

    automation:
      - alias: Heatup
        hide_entity: false
        initial_state: 'off'
        trigger:
          platform: state
          entity_id: sensor.heating_alarm
          from: 'off'
          to: 'on'
        condition:
          condition: state
          entity_id: states.calendar.sauna
          state: 'on'
        action:
          - service: switch.turn_on
            entity_id: switch.saunan_lammitys

Console error is

    2017-12-04 13:27:53 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID states.calendar.sauna is an invalid entity id for dictionary value @ data['condition'][0]['entity_id']. Got None
    extra keys not allowed @ data['condition'][0]['state']. Got None
    not a valid value for dictionary value @ data['condition'][0]['condition']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 86). Please check the docs at https://home-assistant.io/components/automation/
entity_id: states.calendar.sauna

Should be

entity_id: calendar.sauna

Although that suggests you have a calendar called Sauna which I’m guessing you haven’t, so I’m not sure what you’re trying to do with that line.

Yes, that seems to fix the errors & yes, I have a calendar called sauna. When there’s an event in the calendar, I want the sauna heating on.

Is that condition even necessary? Is it already handled in trigger part “from ‘off’ to ‘on’”?

I think you should take that off. Don’t think it will run with that in, unless in another code you are turning it ON. Made that mistake before, and didn’t release until I went via my code one line at a time as I copied and pasted.

Regards

Is it that the ‘initial_state’ is turning that part of automation into not-in-operation state? I thought it was the state of the condition or something…

IT WORKS. Thanks @Odianosen25
:fireworks:

@Kotitonttu,

Glad that helped and you welcome.

Well what it does is that it disables the automation as a whole, and so it wouldn’t run even if triggered. I once use to use it to run as a timer, before the timer component was developed. So initially it is OFF, then in my code I turn it ON/OFF using the homeassistant.turn_xx service.

I still have an issue that if HA is restarted while an event is already scheduled: it doesn’t trigger an action to fire up the relay…

I’ll see if HA turns off the relay when event ends