Skip to content

Commit

Permalink
Merge pull request #20 from caiosweet/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
caiosweet authored Mar 15, 2021
2 parents 71c4559 + 834e785 commit bc7660c
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 378 deletions.
103 changes: 59 additions & 44 deletions examples/hub_automations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ automation:
- platform: state
entity_id: sensor.centro_notifiche
to: "on"
timeout: 60
timeout: 120
continue_on_timeout: true
- service: script.my_notify
data:
Expand All @@ -71,8 +71,8 @@ automation:
Il sistema è operativo!.
voice: Giorgio
type: tts
google:
media_content_id: https://actions.google.com/sounds/v1/human_voices/human_fart.ogg
# google:
# media_content_id: https://actions.google.com/sounds/v1/human_voices/human_fart.ogg
# media_content_type: sound
default:
- service: "notify.{{notification_service}}"
Expand Down Expand Up @@ -151,7 +151,6 @@ automation:
trigger:
- platform: state
entity_id: person.claudio
from: "not_home"
to: "home"
for: "00:02:00"
action:
Expand Down Expand Up @@ -200,7 +199,6 @@ automation:
trigger:
- platform: state
entity_id: person.claudio
from: "not_home"
to: "home"
for: "00:02:00"
action:
Expand Down Expand Up @@ -369,38 +367,38 @@ automation:
# SEGUIMI - Imposta il Media Player in automatico
#----------------------------------------------------------------------------------------------------#
- alias: Seguimi Hub
mode: queued
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id:
- binary_sensor.motion_sensor_158d000222ccb7 #studio
- binary_sensor.motion_sensor_158d0001e5cfdd #corridoio
# - binary_sensor.motion_sensor_158d0001e5cfdd #corridoio
- binary_sensor.pir_corridoio
- binary_sensor.pir_sala
- binary_sensor.cam_sala
from: "off"
to: "on"
action:
- variables:
studio: "{{is_state('binary_sensor.motion_sensor_158d000222ccb7', 'on')}}"
corridoio: "{{is_state('binary_sensor.pir_corridoio', 'on')}}"
sala: "{{is_state('binary_sensor.pir_sala', 'on') or is_state('binary_sensor.cam_sala', 'on')}}"
- service: input_select.select_option
entity_id: input_select.notification_media_player_alexa
data:
option: >-
{% if is_state("binary_sensor.motion_sensor_158d000222ccb7", "on") %}
Studio
{% elif is_state("binary_sensor.cam_sala", "on") %}
Sala
{% else %}
Gruppo Alexa
{% endif %}
{% if studio %} Studio
{% elif sala %} Sala
{% else %} Gruppo Alexa {% endif %}
- service: input_select.select_option
entity_id: input_select.notification_media_player_google
data:
option: >-
{% if is_state("binary_sensor.motion_sensor_158d000222ccb7", "on") %}
Red
{% elif is_state("binary_sensor.cam_sala", "on") %}
Black
{% elif is_state("binary_sensor.motion_sensor_158d0001e5cfdd", "on") %}
Black due
{% endif %}
{% if studio %} Red
{% elif sala %} Black
{% elif corridoio %} Black due
{% else %} Gruppo Google {% endif %}
#----------------------------------------------------------------------------------------------------#
# HACS - Updates
Expand Down Expand Up @@ -472,42 +470,29 @@ automation:
message: Autenticazione Richiesta
notify: pushover
link: "[Integrazioni]({{external_url}}/config/integrations)"
# link Markdown --> [Nome link](LINK)
# link html --> <a href="LINK">"Nome link"</a>
# link Markdown --> [Nome link](LINK)
# link html --> <a href="LINK">"Nome link"</a>

#----------------------------------------------------------------------------------------------------#
# Test trigger event - Notifica location
#----------------------------------------------------------------------------------------------------#
- alias: Notifica location
initial_state: true
trigger:
# - platform: state
# entity_id:
# - person.claudio
- platform: event
event_type: state_changed
condition:
# - "{{ trigger.to_state is not none
# and (trigger.from_state is none or trigger.to_state.state != trigger.from_state.state) }}"

condition: # ??trigger.event.data.old_state is none
- "{{ trigger.event.data.entity_id.startswith('person') }}"
- "{{trigger.event.data.old_state is not none
and (trigger.event.data.old_state is none or trigger.event.data.new_state.state != trigger.event.data.old_state.state)
}}"
- "{{ trigger.event.data.old_state is not none
and (trigger.event.data.old_state is none
or trigger.event.data.new_state.state != trigger.event.data.old_state.state) }}"
action:
- variables:
# lat: "{{trigger.to_state.attributes.latitude}}"
# long: "{{trigger.to_state.attributes.longitude}}"
# from: "{{trigger.from_state.state if trigger.from_state is not none else 'sconosciuto'}}"
# to: "{{trigger.to_state.state}}"
# name: "{{trigger.to_state.name}}"

lat: "{{trigger.event.data.new_state.attributes.latitude}}"
long: "{{trigger.event.data.new_state.attributes.longitude}}"
from: "{{trigger.event.data.old_state.state if trigger.event.data.old_state is not none else 'sconosciuto'}}"
to: "{{trigger.event.data.new_state.state}}"
name: "{{trigger.event.data.new_state.attributes.friendly_name}}"

- service: script.my_notify
data:
alexa: true
Expand All @@ -517,10 +502,6 @@ automation:
{% set from = state_dict.get(from, from) %}
{% set to = state_dict.get(to, to) %}
{{ name }} si è spostato da {{ from }} a {{ to }}
# link: >
# {% if lat and not to in 'home' %}
# [Mappa](https://www.openstreetmap.org/?mlat={{lat}}&mlon={{long}}#map=8/{{lat}}/{{long}})
# {% endif %}
- choose:
- conditions: "{{not to in 'home' and lat != ''}}"
sequence:
Expand All @@ -530,3 +511,37 @@ automation:
latitude: "{{lat}}"
longitude: "{{long}}"
# target: target

#----------------------------------------------------------------------------------------------------#
# Notifica Person location
#----------------------------------------------------------------------------------------------------#
# - alias: Notifica Person location
# initial_state: true
# trigger:
# - platform: state
# entity_id:
# - person.claudio
# condition:
# - "{{ trigger.to_state is not none
# and (trigger.from_state is none or trigger.to_state.state != trigger.from_state.state) }}"
# action:
# - variables:
# lat: "{{trigger.to_state.attributes.latitude}}"
# long: "{{trigger.to_state.attributes.longitude}}"
# from: "{{trigger.from_state.state if trigger.from_state is not none else 'sconosciuto'}}"
# to: "{{trigger.to_state.state}}"
# name: "{{trigger.to_state.name}}"
# - service: script.my_notify
# data:
# alexa: true
# title: "📍 Location {{name}}"
# message: >
# {% set state_dict = {'home': 'Casa', 'not_home': 'Fuori Casa'} %}
# {% set from = state_dict.get(from, from) %}
# {% set to = state_dict.get(to, to) %}
# {{ name }} si è spostato da {{ from }} a {{ to }}
# link: >
# {% if lat and not to in 'home' %}
# [Mappa](https://www.openstreetmap.org/?mlat={{lat}}&mlon={{long}}#map=8/{{lat}}/{{long}})
# {% endif %}

27 changes: 0 additions & 27 deletions extra/binary_sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,3 @@ binary_sensor:
add_holidays:
- '2020-08-31'
- '2021-08-31'

- platform: template
sensors:
people_home:
friendly_name: Persone in casa
device_class: presence
value_template: "{{is_state('group.location_tracker','home')}}"
icon_template: >-
{% set people = expand('group.location_tracker')|selectattr('state','eq','home')
|list|count+(1 if is_state('input_boolean.guest_mode','on') else 0) %}
{% set icon = {0 :'mdi:account-off',
1 :'mdi:account',
2 :'mdi:account-multiple',
3 :'mdi:account-multiple-check'} %}
{{icon[people] if people in icon else 'mdi:account-group'}}
attribute_templates:
number: >-
{% if is_state('group.location_tracker','home')%}
{{expand('group.location_tracker')|selectattr('state','eq','home')
|list|count+(1 if is_state('input_boolean.guest_mode','on') else 0)}}
{%endif%}
name: >-
{% if is_state('group.location_tracker','home')%}
{{expand('group.location_tracker')|selectattr('state','eq','home')
|join(', ',attribute='name')+(', Ospiti' if is_state('input_boolean.guest_mode','on') else '')}}
{%endif%}
Loading

0 comments on commit bc7660c

Please sign in to comment.