Help with automation

Can someone please help me understand why this is not working?

hass@hass:~/.homeassistant/includes/automation$ cat mode_day.yaml
---
- alias: 'Day Mode'
  trigger:
    - platform: numeric_state
      entity_id: sensor.living_room_4in1_luminance_8
      above: 40
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_select.house_mode
        state: Morning
      - condition: time
        after: '09:00:00'
        before: '17:00:00'
      - condition: state
        entity_id: input_boolean.automation_override
        state: 'off'
  action:
    - service: notify.all
      data:
        message: 'Switching to Day mode.'
        data:
          sound: siren
    - service: script.transition_day
hass@hass:~/.homeassistant/includes/automation$ curl -s -X GET -H "Content-Type: application/json" http://hass:8123/api/states | jq '.[] | select(.entity_id|contains("automation.day_mode")) | {entity_id, state}'
{
  "entity_id": "automation.day_mode",
  "state": "on"
}
hass@hass:~/.homeassistant/includes/automation$ curl -s -X GET -H "Content-Type: application/json" http://hass:8123/api/states | jq '.[] | select(.entity_id|contains("sensor.living_room_4in1_luminance_8")) | {entity_id, state}'
{
  "entity_id": "sensor.living_room_4in1_luminance_8",
  "state": "44.25"
}
hass@hass:~/.homeassistant/includes/automation$ curl -s -X GET -H "Content-Type: application/json" http://hass:8123/api/states | jq '.[] | select(.entity_id|contains("input_select.house_mode")) | {entity_id, state}'
{
  "entity_id": "input_select.house_mode",
  "state": "Morning"
}

hass@hass:~/.homeassistant/includes/automation$ date
Sat 1 Oct 09:45:18 CDT 2016

hass@hass:~/.homeassistant/includes/automation$ curl -s -X GET -H “Content-Type: application/json” http://hass:8123/api/states | jq ‘.[] | select(.entity_id|contains(“input_boolean.automation_override”)) | {entity_id, state}’
{
“entity_id”: “input_boolean.automation_override”,
“state”: “off”
}


This is driving me insane, I have upgraded to 0.29.5 and have always had trouble with this particular automation. I'm now using time instead of the sun as a condition to make troubleshooting a bit easier. Since I have upgraded previous automations that have worked in the past are triggering randomly now it seems. I'm just guessing that of all of the examples I have stolen to try and piece this together that I may be doing something stupid now and would really just like a fresh set of eyes on it.

For anyone that takes the time, I really do appreciate it... thank you.

@jceloria

It looks pretty good to me but I am just a noob. What error(s) are you getting?

I am not sure if it matters but you don’t need quotes around your alias.

- alias: Day Mode

Have you tried using a template trigger? Something along these lines…

- platform: template
  value_template: "{{ states('sensor.living_room_4in1_luminance_8') > '40' }}"

For the action should it be:

- service: script.turn_on
  entity_id: script.transition_day

Is the siren a separate entity?

No errors, its impossible to get anything useful out of the logbook due to the amount of times I’m reloading/restarting. I haven’t tried the template trigger because I have another automation that uses the same device only < 40 and it works everyday. The siren is a sound option for pushover.net.

In your conditions,

state: Morning

should probably be

state: 'Morning'

The following is perfectly valid:

- service: script.transition_day

This is the alternative, but not required:

- service: script.turn_on
  entity_id: script.transition_day
1 Like

I appreciate it, I will change over my other automations as well… What is throwing me off is that the others that work all have similar conditions.

I will try quotes. Thanks.

Turns out home-assistant was segfaulting pretty frequently and 0.29.6 with fix 3453 seems to be helping. I had systemd set to restart on failure which was causing some of my zwave devices to change state on startup and causing them to trigger some of my automations.

So thank you for the template trigger idea. In addition to the crashes/restarts that was fixed in the latest release, I’ve also noticed that the battery powered multisensor I was using wasn’t extremely reliable to trigger off of.

I’m not currently using a template trigger, but it did get me thinking about other possible solutions. The one I came up with was to create a template sensor that averages out the light levels of 3 multisensors throughout the house. Since creating the template sensor, I’m not getting false triggers and the automation has generally been way more reliable.

1 Like