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.
rpitera
(Robert Pitera)
January 25, 2017, 10:02pm
2
You need to use data_template:
instead of data:
when you are including values like {{ states.sensor.time.state }}
in your message.
rpitera:
data_template:
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'
rpitera
(Robert Pitera)
January 25, 2017, 11:01pm
4
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>>
rpitera
(Robert Pitera)
January 25, 2017, 11:08pm
6
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
#automation: !include automation.yaml
uncommented, now all work
rpitera
(Robert Pitera)
January 25, 2017, 11:12pm
9
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 }}'
rpitera
(Robert Pitera)
January 25, 2017, 11:53pm
11
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!
oriolism
(Oriolism)
January 26, 2017, 1:23am
12
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!
rpitera
(Robert Pitera)
January 26, 2017, 2:23pm
14
Just on it’s own, or did you see something that you had to change?
oriolism
(Oriolism)
January 26, 2017, 2:50pm
15
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
rpitera
(Robert Pitera)
January 26, 2017, 2:52pm
16
Cool; I just wanted to know if the example I gave was of any help.