Advertisement
calas

Rilevamento automatico ospiti

Jun 30th, 2022 (edited)
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.72 KB | None | 0 0
  1.  
  2. ################################################################################
  3. ##                  Sensor
  4. ################################################
  5. sensor:
  6.   - platform: template
  7.     sensors:
  8.       netatmo_type:
  9.         friendly_name: "Netatmo tipo di rilevamento"
  10.         value_template: >
  11.          {%- if is_state('sensor.nacamera_tipo_evento', 'person') %}
  12.               Persone
  13.           {%- elif is_state('sensor.nacamera_tipo_evento', 'movement') %}
  14.               Movimento
  15.           {%- elif is_state('sensor.nacamera_tipo_evento', 'changed') %}
  16.               Info
  17.           {% endif %}
  18.         icon_template: >
  19.          {%- if is_state('sensor.nacamera_tipo_evento', 'person') %}
  20.               mdi:account-star
  21.           {%- elif is_state('sensor.nacamera_tipo_evento', 'movement') %}
  22.               mdi:motion-sensor
  23.           {%- elif is_state('sensor.nacamera_tipo_evento', 'topology_changed') %}
  24.               mdi:information-variant
  25.           {% endif %}
  26.  
  27.       ospiti_count:
  28.         friendly_name: conteggio ospiti
  29.         value_template: >-
  30.           {{ states.device_tracker | selectattr('state', 'eq', 'home') | selectattr('attributes.ssid', 'eq', 'LAN SOLO OSPITI') | list | count }}
  31.  
  32.  
  33. ################################################################################
  34. ##                  Template
  35. ################################################
  36. template:
  37.   - trigger:
  38.       - platform: event
  39.         event_type: netatmo_event
  40.     sensor:
  41.       - name: "NACamera name"
  42.         state: "{{trigger.event.data['data']['name'] | default('nessuno')}}"
  43.       - name: "NACamera conosciuto"
  44.         state: "{{trigger.event.data['data']['is_known'] | default('false')}}"
  45.       - name: "NACamera tipo evento"
  46.         state: "{{trigger.event.data['data']['event_type']}}"
  47.     binary_sensor:
  48.       - name: rilevamento ospiti check
  49.         auto_off: 15
  50.         state: "true"
  51.  
  52.   - trigger:
  53.       - platform: template
  54.         value_template: >-
  55.           {%- if is_state("sensor.nacamera_tipo_evento", "person") and
  56.               is_state("sensor.nacamera_conosciuto", "True") and
  57.               states('sensor.nacamera_name') != 'Francesco' and
  58.               states('sensor.nacamera_name') != 'Simona' and
  59.               states('sensor.nacamera_name') != 'Gaia' and
  60.               states('sensor.nacamera_name') != 'Emma' and
  61.               states('sensor.nacamera_name') != 'Fabiana' %}
  62.                 true
  63.           {% endif %}
  64.     binary_sensor:
  65.       - name: netatmo_rilevamento_ospiti
  66.         auto_off: 900
  67.         state: "true"
  68.  
  69. ################################################################################
  70. ##                  Automation
  71. ################################################
  72. automation:
  73.   - alias: Netatmo Event
  74.     id: 01GBA727Y5XGTZ99JGQK4BG5DX
  75.     description: Eventi Netatmo
  76.     trigger:
  77.       - event_data: {}
  78.         event_type: netatmo_event
  79.         platform: event
  80.     action:
  81.       - condition: template
  82.         value_template: >-
  83.           {{ trigger.event.data['data']['event_type'] == 'person' }}
  84.       - service: notify.netatmo_log
  85.         data_template:
  86.           message: >-
  87.             [{{ now().strftime('%d/%m/%Y - %H:%M') }}] - {{ trigger.event.data.data.name }}
  88.  
  89.   - alias: Netatmo modo ospiti auto on
  90.     id: 01GBA72F5NZQ4RH12JD16CQ5PT
  91.     description: Eventi Netatmo
  92.     trigger:
  93.       - platform: state
  94.         entity_id: binary_sensor.netatmo_rilevamento_ospiti
  95.         to: "on"
  96.       - platform: template
  97.         value_template: >-
  98.           {{ states('sensor.ospiti_count') > '0' }}
  99.         for:
  100.           minutes: 3
  101.     condition:
  102.       - condition: state
  103.         entity_id: input_boolean.riconoscimento_ospiti
  104.         state: "on"
  105.       - condition: state
  106.         entity_id: group.famiglia
  107.         state: "home"
  108.     action:
  109.       - service: input_boolean.turn_on
  110.         target:
  111.           entity_id: input_boolean.modo_ospite
  112.  
  113.   - alias: Netatmo modo ospiti auto off
  114.     id: 01GBA72NY9YNW5AQYQBAGAPAAF
  115.     description: Eventi Netatmo
  116.     mode: restart
  117.     max_exceeded: silent
  118.     trigger:
  119.       - platform: state
  120.         entity_id: binary_sensor.netatmo_rilevamento_ospiti
  121.         to: "off"
  122.         for:
  123.           minutes: 15
  124.       - platform: state
  125.         entity_id: binary_sensor.rilevamento_ospiti_check
  126.         to: "off"
  127.     condition:
  128.       condition: state
  129.       entity_id: binary_sensor.netatmo_rilevamento_ospiti
  130.       state: "off"
  131.     action:
  132.       - wait_template: "{{ is_state('sensor.ospiti_count', '0') }}"
  133.       - service: input_boolean.turn_off
  134.         target:
  135.           entity_id: input_boolean.modo_ospite
  136.  
  137.   - alias: Netatmo modo ospiti annuncio
  138.     id: 01GBA72WJPBS2JDQ10YM2YA9PZ
  139.     description: Eventi Netatmo
  140.     mode: restart
  141.     max_exceeded: silent
  142.     trigger:
  143.       - platform: state
  144.         entity_id: input_boolean.modo_ospite
  145.         to: "off"
  146.         id: "off"
  147.       - platform: state
  148.         entity_id: input_boolean.modo_ospite
  149.         to: "on"
  150.         id: "on"
  151.     action:
  152.       - choose:
  153.           - conditions:
  154.               - condition: trigger
  155.                 id: "off"
  156.             sequence:
  157.               - service: script.multinotify
  158.                 data:
  159.                   title: Sicurezza
  160.                   message: modalità ospite, disattivata
  161.                   alexa_target: media_player.in_casa
  162.           - conditions:
  163.               - condition: trigger
  164.                 id: "on"
  165.             sequence:
  166.               - service: script.multinotify
  167.                 data:
  168.                   title: Sicurezza
  169.                   message: modalità ospite, attivata
  170.                   alexa_target: media_player.in_casa
  171.  
  172.  
  173.   - alias: Netatmo modo ospiti off modo vacanza
  174.     id: 01GBA73DT78YBHK04XE649G8K3
  175.     description: Eventi Netatmo
  176.     mode: restart
  177.     max_exceeded: silent
  178.     trigger:
  179.       - platform: state
  180.         entity_id: binary_sensor.netatmo_rilevamento_ospiti
  181.         to: "off"
  182.         for:
  183.           minutes: 15
  184.       - platform: state
  185.         entity_id: binary_sensor.rilevamento_ospiti_check
  186.         to: "off"
  187.     condition:
  188.       - condition: state
  189.         entity_id: binary_sensor.netatmo_rilevamento_ospiti
  190.         state: "off"
  191.       - condition: state
  192.         entity_id: input_boolean.allarme_modo_vacanze
  193.         state: "on"
  194.       - condition: state
  195.         entity_id: group.famiglia
  196.         state: "not_home"
  197.     action:
  198.       - wait_template: "{{ is_state('sensor.ospiti_count', '0') }}"
  199.       - service: script.multinotify
  200.         data:
  201.           title: Sicurezza
  202.           message: Ospiti fuori casa
  203.       - service: alarm_control_panel.alarm_arm_away
  204.         data:
  205.           code: "6400"
  206.         target:
  207.           entity_id: alarm_control_panel.allarme
  208.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement