I was curious if someone could give me a nudge in the right direction…
My configuration is very simple at this point but what I want to do is create a simple notification to understand how the system works.
For my first test I’d like to send a notification via telegram when I turn on / off a z wave switch
I already have the z-wave switch installed and configured and I already have telegram configured and ready to send messages.
I assume I will be using a simple modification of the example given in the “geting started with automation” section:
automation:
# Notify me on my mobile phone of an event
action:
service: notify.notify
data:
message: Something just happened, better take a look!
I am using a friendly name for the z-wave switch and have called it Switch-1
How would i trigger the automation system to send a message to tell me when the switch has been turned on and turned off?
Thanks for the help!
Edit:
To be a little more clear this is the flow that I’d like to happen:
Push button to turn switch on -> received notfication that the switch has been turned on.
Also in the same situation here using pushbullet (sorry to jump in with this pushbullet, but i think it doesnt matter if telegram or any other notify service)
How do you associate a notification to a switch?
automation:
- alias: 'RULE1 - Night Light ON at 10:30pm'
trigger:
- platform: time
hours: 22
minutes: 30
action:
service: switch.turn_on
entity_id: switch.night_light
Then I added extra lines below, notification get sent out but the switch does not turn on.
- alias: 'RULE1 - Night Light ON at 10:30pm'
trigger:
- platform: time
hours: 22
minutes: 30
action:
service: switch.turn_on
entity_id: switch.night_light
service: notify.pushie
data:
title: "Night Light On"
message: "Night light is now on"
@kwetiaw you can’t use two (or more) service calls in the same action. You should use the script component
@TheBeeman for automation you should use entity_id, not friendly_name
Something like…
automation:
trigger:
platform: state
entity_id: switch.whatever_entity_name_you_have
#if you want either both notifications (on/off), don't put here any state condition, as stated here -> https://home-assistant.io/components/automation/#state-trigger
action:
service: notify.notify
data:
message: "Switch has changed"
Thanks for the reply…
I think this is on the right track as the suggested config that you gave doesn’t break home assistant and stop it from starting up like my attempts did =D
However: When i turn the switch on/off nothing happens. It doesn’t trigger a message to be sent by telegram.
I did of course replace the entity_id with the appropriate id - this is from my config file:
automation:
trigger:
platform: state
entity_id: switch.aeon_labs_smart_energy_switch_switch
action:
service: notify.notify
data:
message: “Switch has changed”
And just to show you that my telegram bot is setup correctly:
notify:
name: notify
platform: telegram
api_key: redacted
chat_id: redacted
I think I must be 90% of the way there im just missing something simple.
I think i’ve found my problem.
I’m almost sure that my entity_id is incorrect. I was just using the name that was listed in the “set state” tab which now that I look is “switch.aeotec_smart_energy_switch_switch_2” vs “switch.aeon_labs_smart_energy_switch_switch” as I was using before. (that was the name the last time i looked)
However, when I change this to the new name it still doesn’t fix the issue.
How can I be sure tha tI am using the correct entity_id?
All entity_id that HA recognizes are in the developer tools (the list that appears pressing <>)
Try setting trigger to the ‘on’ state, to see if that triggers notification, and add (just to try), title to telegram notification mesage…
automation:
trigger:
platform: state
entity_id: switch.aeotec_smart_energy_switch_switch_2
to: 'on'
action:
service: notify.notify
data:
title: "Hello!"
message: "Switch has changed"
Okay. So there’s some kind of weird background issue with my zwave dongle i think. on Some reboots on my pi the entity_id is changing. If i reboot again it seems to fix the issue. Weird…
anyway. your example works when i set it to measure “on” and added the title per your example.
What route do i need to go to setup another one for off? i tried just doing a duplicate trigger except set to ‘off’ but it complained about it being a duplicate.