From b7fd741c06aa3b8b0eca73fcd92ecbf8ad322d34 Mon Sep 17 00:00:00 2001 From: CCOSTAN Date: Thu, 1 Dec 2016 01:17:52 +0000 Subject: [PATCH] Using IFTTT as a script using a data template and variables! --- automation/bad_logins.yaml | 8 ++++++-- automation/device_status.yaml | 10 ++++------ automation/startup_notification.yaml | 10 ++++------ automation/update_notification.yaml | 7 +++++-- configuration.yaml | 2 +- customize/homeassistant.yaml | 3 +++ group/views.yaml | 1 + script/ifttt_notify.yaml | 5 ++++- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/automation/bad_logins.yaml b/automation/bad_logins.yaml index f522a042..060b805d 100755 --- a/automation/bad_logins.yaml +++ b/automation/bad_logins.yaml @@ -8,6 +8,10 @@ platform: numeric_state entity_id: sensor.badlogin above: 1 + action: - service: ifttt.trigger - data: {"event":"ifttt_notify", "value1":"Home Assistant Error: ", "value2":"Login Failure Detected"} + service: script.ifttt_notify + data_template: + value1: 'Bad Login: ' + value2: 'There was a Hack attempt!' + value3: '' diff --git a/automation/device_status.yaml b/automation/device_status.yaml index e2009f56..eeeb9bc0 100755 --- a/automation/device_status.yaml +++ b/automation/device_status.yaml @@ -25,10 +25,8 @@ - sensor.garadget_small - sensor.garadget_large action: - service: script.turn_on - entity_id: script.notify_ifttt + service: script.ifttt_notify data_template: - variables: - value1: 'Device Status ' - value2: "{{ trigger.entity_id.split('.')[1] }} is " - value3: "{{ trigger.to_state.state }}" + value1: 'Device Status:' + value2: "{{ trigger.entity_id.split('.')[1] }} is " + value3: "{{ trigger.to_state.state }}" diff --git a/automation/startup_notification.yaml b/automation/startup_notification.yaml index d41b0501..fb1104cd 100755 --- a/automation/startup_notification.yaml +++ b/automation/startup_notification.yaml @@ -8,10 +8,8 @@ platform: event event_type: homeassistant_start action: - service: script.turn_on - entity_id: script.notify_ifttt + service: script.ifttt_notify data_template: - variables: - value1: "Startup: Home Assistant is Up and Running!" - value2: "" - value3: "" + value1: 'Startup: Home Assistant is Up and Running!' + value2: '' + value3: '' diff --git a/automation/update_notification.yaml b/automation/update_notification.yaml index de6676d0..5ba95113 100755 --- a/automation/update_notification.yaml +++ b/automation/update_notification.yaml @@ -9,8 +9,11 @@ value_template: "{{ states('updater.updater') != 'unknown' }}" action: - - service: ifttt.trigger - data: {"event":"ifttt_notify", "value1":"Home Assistant Update: ", "value2":"Available"} + - service: script.ifttt_notify + data_template: + value1: 'There is a new Version of Home-Assistant Available.' + value2: "{{ states('updater.updater') }}" + value3: '' - service: notify.html5 data_template: diff --git a/configuration.yaml b/configuration.yaml index 066ccdcc..c5debfae 100755 --- a/configuration.yaml +++ b/configuration.yaml @@ -105,5 +105,5 @@ sensor: !include_dir_merge_list sensor automation: !include_dir_merge_list automation scene: !include_dir_merge_list scene switch: !include_dir_merge_list switch -script: !include_dir_merge_list script +script: !include_dir_merge_named script input_boolean: !include_dir_merge_named input_boolean diff --git a/customize/homeassistant.yaml b/customize/homeassistant.yaml index 52f3d9a2..f7cfa775 100755 --- a/customize/homeassistant.yaml +++ b/customize/homeassistant.yaml @@ -29,6 +29,9 @@ group.all_lights: group.all_switches: hidden: false +group.all_scripts: + hidden: false + group.all_automations: emulated_hue: false hidden: false diff --git a/group/views.yaml b/group/views.yaml index d76a3b88..a83eaddf 100755 --- a/group/views.yaml +++ b/group/views.yaml @@ -70,3 +70,4 @@ Info: - group.all_lights - group.all_switches - group.all_automations + - group.all_scripts diff --git a/script/ifttt_notify.yaml b/script/ifttt_notify.yaml index dd93852b..a776b910 100755 --- a/script/ifttt_notify.yaml +++ b/script/ifttt_notify.yaml @@ -1,5 +1,8 @@ +###################################################################################################### +###Script to send notifications to IFTTT to notify me on the mobile Phone! +###################################################################################################### -notify_ifttt: +ifttt_notify: sequence: - service: ifttt.trigger data_template: {"event":"ifttt_notify", "value1":"{{ value1 }}", "value2":"{{ value2 }}", "value3":"{{ value3 }}"}