Automation trigger not working

Hey

Can’t figure out what is wrong, why it doesn’t work when i switch on the kitchen lights, can you see what is it?

automation:
  alias: test2
    trigger:
      platform: state
        entity_id: switch.kitchen_lights
        state: 'on'
    action:
      service: notify.slack
        data:
          message: 'Fired at {{ states.sensor.time.state }}'  

Other notifications work fine.

You need to use data_template: instead of data: when you are including values like {{ states.sensor.time.state }} in your message.

nope, same not working, also tried:

  - alias: test2
    - trigger:
        platform: state
          entity_id: switch.kitchen_lights
          state: 'on'
    - action:
        service: notify.slack
          data:
            message: 'test'

Are you using the right name for the service? I saw another post you did where you had the wrong name.

What kind of error are you getting in your logs?

no, the notifications works good, i use them for debug. i mean i can fire notifications from scripts without any problem. nothing in log related automation, the switch shows:

INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=homeassistant, service=turn_on, service_data=entity_id=switch.kitchen_lights, service_call_id=3052872272-9>
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=switch, service=turn_on, service_data=entity_id=['switch.kitchen_lights'], service_call_id=3052872272-10>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=switch.kitchen_lights, old_state=<state switch.kitchen_lights=off; friendly_name=Kitchen Lights, assumed_state=True, icon=mdi:lightbulb-outline @ 2017-01-26T01:04:21.462782+02:00>, new_state=<state switch.kitchen_lights=on; friendly_name=Kitchen Lights, assumed_state=True, icon=mdi:lightbulb-outline @ 2017-01-26T01:04:28.038343+02:00>>

So the problem is your trigger. But you will still have to use data_template to get the message to send correctly once you figure that out. Otherwise it will literally read “Fired at {{ states.sensor.time.state }}” instead of “Fired at 12:00”.

found it :confused:

#automation: !include automation.yaml

uncommented, now all work

Here’s how you do the data template portion:

    action:
      service: notify.slack
      data_template:
        message: >
          Fired at {{ states.sensor.time.state }}

donno, this working good for me:

  - service: notify.slack
    data:
      message: 'Fired at {{ states.sensor.time.state }}'

I guess slack is different than some of the other notify platforms; I don’t use it so I appreciate the info from you about this working. I’ll have to file that away in case someone else asks.

Glad you’re good though!

Sorry to hijack this post but i have a similar problem with this automation. My problem is that I don’t receive the notification.

- alias: High Humidity in Isabella's Room
  trigger:
    platform: numeric_state
    entity_id: sensor.isabellas_room_2
    above: 56
  action:
    - service: notify.pushbullet
      data_template:
        title: "High Humidity - Isabella's Room"
        data: The Humidity is currently {{ states("sensor.isabellas_room_2") }}
    - service: switch.turn_on
      entity_id: switch.dehumidifier

In configuration.yaml

notify:
  - name: PushBullet
    platform: pushbullet
   api_key: redacted!

Any help will be appreciated!

Ok, it’s working now.

Just on it’s own, or did you see something that you had to change?

I change the configuration to:

- alias: High Humidity in Isabella's Room
  trigger:
    platform: numeric_state
    entity_id: sensor.isabellas_room_2
    above: 56
  action:
    - service: notify.PushBullet
      data_template:
        title: "High Humidity - Isabella's Room"
        message: >
          The Humidity is currently {{ states("sensor.isabellas_room_2") }}
    - service: switch.turn_on
      entity_id: switch.dehumidifier

Cool; I just wanted to know if the example I gave was of any help.