Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- homeassistant:
- customize:
- package.node_anchors:
- customize: &customize
- package: 'Package Allarme'
- version: 'v1.1'
- author: 'Calas'
- expose: &expose
- <<: *customize
- haaska_hidden: false
- homebridge_hidden: false
- ################################################
- ## Input Boolean Customize
- ################################################
- input_boolean.allamre_manuale:
- <<: *customize
- input_boolean.allamre_automatico_in_casa:
- <<: *customize
- input_boolean.allamre_automatico_notte:
- <<: *customize
- input_boolean.allamre_automatico_away:
- <<: *customize
- input_boolean.allarme_telefonata:
- <<: *customize
- input_boolean.allarme_invio_foto:
- <<: *customize
- input_boolean.sensore_finestra_camera_in_casa:
- <<: *customize
- input_boolean.sensore_finestra_camera_notte:
- <<: *customize
- input_boolean.sensore_finestra_camera_away:
- <<: *customize
- input_boolean.sensore_finestra_camera_manuale:
- <<: *customize
- input_boolean.sensore_porta_ingresso_in_casa:
- <<: *customize
- input_boolean.sensore_porta_ingresso_notte:
- <<: *customize
- input_boolean.sensore_porta_ingresso_away:
- <<: *customize
- input_boolean.sensore_porta_ingresso_manuale:
- <<: *customize
- input_boolean.sensore_pir_corridoio_in_casa:
- <<: *customize
- input_boolean.sensore_pir_corridoio_notte:
- <<: *customize
- input_boolean.sensore_pir_corridoio_away:
- <<: *customize
- input_boolean.sensore_pir_corridoio_manuale:
- <<: *customize
- input_boolean.cam1:
- <<: *customize
- ################################################
- ## Input Binary Sensor Customize
- ################################################
- binary_sensor.allarme_in_casa:
- <<: *customize
- binary_sensor.allarme_away:
- <<: *customize
- binary_sensor.allarme_notte:
- <<: *customize
- ################################################
- ## Input Datetime Customize
- ################################################
- input_datetime.allarme_notte_start:
- <<: *customize
- input_datetime.allarme_notte_end:
- <<: *customize
- #******************************************************************************#
- # C O R P O #
- #******************************************************************************#
- ################################################
- ## Integrazioni
- ################################################
- twilio:
- account_sid: !secret twilio_account_sid
- auth_token: !secret twilio_auth_token
- ################################################
- ## Input Datetime
- ################################################
- input_datetime:
- allarme_notte_start:
- name: Inizio Allarme Notturno
- has_date: false
- has_time: true
- allarme_notte_end:
- name: Fine Allarme Notturno
- has_date: false
- has_time: true
- ################################################
- ## Input Boolean
- ################################################
- input_boolean:
- allamre_manuale:
- name: Manuale
- icon: mdi:cursor-pointer
- allamre_automatico_in_casa:
- name: Auto in casa
- icon: mdi:shield-home
- allamre_automatico_notte:
- name: Auto Notte
- icon: mdi:weather-night
- allamre_automatico_away:
- name: Auto fuori casa
- icon: mdi:alarm-light
- allarme_telefonata:
- name: Invio telefonata
- icon: mdi:phone-alert
- allarme_invio_foto:
- name: Invio foto
- icon: mdi:camera
- controllo_stato_cam:
- name: Controllo CAM
- icon: mdi:motion-sensor
- sensore_finestra_camera_in_casa:
- name: Finestra Camera
- icon: mdi:window-open-variant
- sensore_finestra_camera_notte:
- name: Finestra Camera
- icon: mdi:window-open-variant
- sensore_finestra_camera_away:
- name: Finestra Camera
- icon: mdi:window-open-variant
- sensore_finestra_camera_manuale:
- name: Finestra Camera
- icon: mdi:window-open-variant
- sensore_porta_ingresso_in_casa:
- name: Porta Ingresso
- icon: mdi:door-closed-lock
- sensore_porta_ingresso_notte:
- name: Porta Ingresso
- icon: mdi:door-closed-lock
- sensore_porta_ingresso_away:
- name: Porta Ingresso
- icon: mdi:door-closed-lock
- sensore_porta_ingresso_manuale:
- name: Porta Ingresso
- icon: mdi:door-closed-lock
- sensore_pir_corridoio_in_casa:
- name: PIR Corridoio
- icon: mdi:motion-sensor
- sensore_pir_corridoio_notte:
- name: PIR Corridoio
- icon: mdi:motion-sensor
- sensore_pir_corridoio_away:
- name: PIR Corridoio
- icon: mdi:motion-sensor
- sensore_pir_corridoio_manuale:
- name: PIR Corridoio
- icon: mdi:motion-sensor
- cam1:
- name: Cam1
- ################################################
- ## Sensor
- ################################################
- sensor:
- - platform: template
- sensors:
- allarme:
- friendly_name_template: "Allarme"
- entity_id: alarm_control_panel.allarme
- value_template: "{{ {
- 'disarmed' : 'Disattivato',
- 'armed_home' : 'In Casa',
- 'armed_away' : 'Attivo',
- 'armed_night' : 'Notte',
- } [states('alarm_control_panel.allarme')] }}"
- stato_allarme:
- friendly_name: 'stato allarme'
- value_template: >-
- {%- if states.alarm_control_panel.allarme.state != "disarmed" -%}
- Armato
- {%- elif states.alarm_control_panel.allarme.state == "disarmed" -%}
- Disarmato
- {% else %}
- Sconosciuto
- {% endif %}
- ################################################
- ## Binary Sensor
- ################################################
- binary_sensor:
- - platform: template # ALLARME
- sensors:
- allarme_in_casa:
- value_template: "{{ is_state('sensor.allarme', 'In Casa') }}"
- allarme_away:
- value_template: "{{ is_state('sensor.allarme', 'Attivo') }}"
- allarme_notte:
- value_template: "{{ is_state('sensor.allarme', 'Notte') }}"
- allarme_disattivato:
- value_template: "{{ is_state('sensor.allarme', 'Disattivato') }}"
- cam1_stato:
- friendly_name: WebCam 1
- device_class: power
- entity_id: switch.cam1
- value_template: "{{ is_state('switch.cam1', 'on') }}"
- icon_template: >-
- {% if is_state('switch.cam1', 'on') %}
- mdi:video
- {% elif is_state('switch.cam1', 'off') %}
- mdi:video-off-outline
- {% else %}
- mdi:video-off-outline
- {% endif %}
- - platform: ping # Ping WEBCAM
- name: 'Cam1'
- host: !secret ip_cam1
- scan_interval: 300
- ################################################
- ## Automations
- ################################################
- automation:
- ################################################### ATTIVAZIONE ALLARMI ########
- - alias: Allarme auto away ON
- initial_state: true
- trigger:
- - entity_id: group.XXXXXXXXX
- from: 'home'
- platform: state
- to: 'not_home'
- condition:
- - condition: state
- entity_id: input_boolean.allamre_automatico_away
- state: 'on'
- - condition: state
- entity_id: input_boolean.modo_ospite
- state: 'off'
- action:
- - service: alarm_control_panel.alarm_arm_away
- data: {"entity_id":"alarm_control_panel.allarme","code":"XXXXXX"}
- - service: mqtt.publish
- data_template:
- payload: "away"
- topic: allarme/attivazione
- retain: false
- qos: 1
- - alias: Allarme auto notte ON
- initial_state: true
- trigger:
- - platform: template
- value_template: "{{ states('sensor.time') == (states.input_datetime.allarme_notte_start.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
- condition:
- - condition: state
- entity_id: input_boolean.allamre_automatico_notte
- state: 'on'
- - condition: state
- entity_id: input_boolean.modo_ospite
- state: 'off'
- action:
- - service: alarm_control_panel.alarm_arm_night
- data: {"entity_id":"alarm_control_panel.allarme","code":"XXXXXX"}
- - service: switch.turn_on
- data:
- entity_id: switch.cam1
- - service: mqtt.publish
- data_template:
- payload: "notte"
- topic: allarme/attivazione
- retain: false
- qos: 1
- - alias: Allarme Armato Away
- initial_state: true
- trigger:
- platform: state
- entity_id: alarm_control_panel.allarme
- to: 'armed_away'
- action:
- - service: switch.turn_on
- data:
- entity_id: switch.cam1
- - service: notify.alexa_media
- data:
- target:
- - media_player.in_casa
- data:
- type: announce
- method: speak
- message: "Allarme Attivo"
- ################################################### ALLARMI OFF ################
- - alias: "Allarme Away OFF"
- initial_state: true
- trigger:
- - entity_id: group.XXXXXXXXX
- platform: state
- to: 'home'
- condition:
- - condition: state
- entity_id: sensor.stato_allarme
- state: 'Armato'
- action:
- - service: alarm_control_panel.alarm_disarm
- data: {"entity_id":"alarm_control_panel.allarme","code":"XXXXXX"}
- - alias: "Allarme Notte OFF"
- initial_state: true
- trigger:
- - platform: template
- value_template: "{{ states('sensor.time') == (states.input_datetime.allarme_notte_end.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
- action:
- - service: alarm_control_panel.alarm_disarm
- data: {"entity_id":"alarm_control_panel.allarme","code":"XXXXXX"}
- - service: mqtt.publish
- data_template:
- payload: "notte"
- topic: allarme/disattivazione
- retain: false
- qos: 1
- - alias: "Allarmi OFF tasto"
- initial_state: true
- trigger:
- - platform: event
- event_type: xiaomi_aqara.click
- event_data:
- entity_id: binary_sensor.switch_158d0001e85517
- click_type: long_click_press
- action:
- - service: alarm_control_panel.alarm_disarm
- data: {"entity_id":"alarm_control_panel.allarme","code":"XXXXXX"}
- - service: notify.XXXXXXXXX
- data:
- title: '*Allarme OFF*'
- message: L'allarme disinserito con tasto.
- - service: notify.alexa_media
- data:
- target:
- - media_player.in_casa
- data:
- type: announce
- method: speak
- message: "Allarme disattivato con tasto"
- - alias: "Disattivazione Allarme"
- initial_state: true
- trigger:
- - platform: state
- entity_id: sensor.stato_allarme
- to: 'Disarmato'
- action:
- - service: switch.turn_off
- data:
- entity_id: switch.cam1
- ################################################### NOTIFICHE STATO ALLARME ####
- - alias: Notifiche stato allarme
- initial_state: true
- trigger:
- - platform: state
- entity_id: alarm_control_panel.allarme
- condition:
- - condition: template
- value_template: "{{ states.sensor.allarme.state != ''}}"
- action:
- - service: notify.XXXXXXXXX
- data:
- title: '*ALLARME*'
- message: 'Allarme: {{ states.sensor.allarme.state }}'
- ################################################### CONTROLLO STATI CAM ########
- - id: notifica_controllo_accensione_cam_cnt
- alias: Controllo Accensione Cam
- initial_state: true
- trigger:
- platform: state
- entity_id: alarm_control_panel.allarme
- to: 'armed_away'
- for:
- minutes: 6
- condition:
- condition: state
- entity_id: binary_sensor.cam1
- state: 'off'
- action:
- service: notify.XXXXXXXXX
- data:
- message: La webcam non si รจ accesa
- - id: notifica_controllo_se_cam_viene_spenta_cnt
- alias: Controllo se Cam viene spenta
- initial_state: true
- trigger:
- platform: state
- entity_id: binary_sensor.cam1
- to: 'off'
- for:
- minutes: 6
- condition:
- condition: state
- entity_id: binput_boolean.allarme
- state: 'on'
- action:
- service: notify.XXXXXXXXX
- data:
- message: La webcam รจ stata spenta!
- ################################################################################
- ############################## TRIGGER ALLARME #############################
- ################################################################################
- ############################## TRIGGER ALLARME IN CASA #####################
- - alias: 'Allarme In Casa tirgger porta ingresso'
- trigger:
- - platform: state
- entity_id: binary_sensor.door_window_sensor_158d000276e059
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_porta_ingresso_in_casa
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_home
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- - alias: 'Allarme In Casa tirgger finestra cameretta'
- trigger:
- - platform: state
- entity_id: binary_sensor.finestra_cameretta
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_finestra_camera_in_casa
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_home
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- - alias: 'Allarme In Casa tirgger Corridoio'
- trigger:
- - platform: state
- entity_id: binary_sensor.motion_sensor_158d0002b488d7
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_pir_corridoio_in_casa
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_home
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- ############################## TRIGGER ALLARME NOTTE #######################
- - alias: 'Allarme Notte tirgger porta ingresso'
- trigger:
- - platform: state
- entity_id: binary_sensor.door_window_sensor_158d000276e059
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_porta_ingresso_notte
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_night
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- - alias: 'Allarme Notte tirgger finestra cameretta'
- trigger:
- - platform: state
- entity_id: binary_sensor.finestra_cameretta
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_finestra_camera_notte
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_night
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- - alias: 'Allarme Notte tirgger Corridoio'
- trigger:
- - platform: state
- entity_id: binary_sensor.motion_sensor_158d0002b488d7
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_pir_corridoio_notte
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_night
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- ############################## TRIGGER ALLARME NOTTE #######################
- - alias: 'Allarme Away tirgger porta ingresso'
- trigger:
- - platform: state
- entity_id: binary_sensor.door_window_sensor_158d000276e059
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_porta_ingresso_away
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_away
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- - alias: 'Allarme Away tirgger finestra cameretta'
- trigger:
- - platform: state
- entity_id: binary_sensor.finestra_cameretta
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_finestra_camera_away
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_away
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- - alias: 'Allarme Away tirgger Corridoio'
- trigger:
- - platform: state
- entity_id: binary_sensor.motion_sensor_158d0002b488d7
- to: 'on'
- condition:
- - condition: state
- entity_id: input_boolean.sensore_pir_corridoio_away
- state: 'on'
- - condition: state
- entity_id: alarm_control_panel.allarme
- state: armed_away
- action:
- service: alarm_control_panel.alarm_trigger
- entity_id: alarm_control_panel.allarme
- ################################################################################
- ############################## AZIONI ALLARME #############################
- ################################################################################
- ############################## SIRENA #######################################
- - alias: Sirena ON
- initial_state: true
- trigger:
- - platform: state
- entity_id: alarm_control_panel.allarme
- to: 'triggered'
- action:
- - service: xiaomi_aqara.play_ringtone
- data:
- gw_mac: !secret xiaomi_mac
- ringtone_id: 1
- ringtone_vol: 100
- - service: switch.turn_on
- entity_id: switch.sirena
- - service: notify.XXXXXXXXX
- data:
- title: '*ALLARME*'
- message: La sirenza sta suonando.
- - alias: Sirena OFF
- initial_state: true
- trigger:
- - platform: state
- entity_id: alarm_control_panel.allarme
- to: 'disarmed'
- action:
- - service: xiaomi_aqara.stop_ringtone
- data:
- gw_mac: !secret xiaomi_mac
- - service: switch.turn_off
- entity_id: switch.sirena
- ############################## FOTO #########################################
- - alias: Invio Foto Allarme
- initial_state: true
- trigger:
- - platform: state
- entity_id: alarm_control_panel.allarme
- to: 'triggered'
- condition:
- - condition: state
- entity_id: input_boolean.allarme_invio_foto
- state: 'on'
- action:
- - delay: '00:00:01'
- - service: notify.XXXXXXXXX
- data_template:
- message: "Immagine Intrusione"
- data:
- photo:
- - url: 'https://XXXXXXXXX.duckdns.org:8123{{states.camera.soggiorno.attributes.entity_picture}}'
- caption: 'Movimeto rilevato il {{now().strftime("%d.%m.%Y - %H:%M:%S")}}'
- - delay: '00:00:01'
- - service: notify.XXXXXXXXX
- data_template:
- message: "Immagine Intrusione"
- data:
- photo:
- - url: 'https://XXXXXXXXX.duckdns.org:8123{{states.camera.soggiorno.attributes.entity_picture}}'
- caption: 'Immagine 2 {{now().strftime("%d.%m.%Y - %H:%M:%S")}}'
- - delay: '00:00:01'
- - service: notify.XXXXXXXXX
- data_template:
- message: "Immagine Intrusione"
- data:
- photo:
- - url: 'https://XXXXXXXXX.duckdns.org:8123{{states.camera.soggiorno.attributes.entity_picture}}'
- caption: 'Immagine 3 {{now().strftime("%d.%m.%Y - %H:%M:%S")}}'
- - delay: '00:00:02'
- - service: notify.XXXXXXXXX
- data_template:
- message: "Immagine Intrusione"
- data:
- photo:
- - url: 'https://XXXXXXXXX.duckdns.org:8123{{states.camera.soggiorno.attributes.entity_picture}}'
- caption: 'Immagine 3 {{now().strftime("%d.%m.%Y - %H:%M:%S")}}'
- ############################## TELEFONATA ###################################
- - alias: Chiamata Allarme
- initial_state: true
- trigger:
- - platform: state
- entity_id: alarm_control_panel.allarme
- to: 'triggered'
- condition:
- - condition: state
- entity_id: input_boolean.allarme_telefonata
- state: 'on'
- action:
- service: notify.allarme
- data:
- message: 'Allarm On'
- target:
- - +393921220821
- - +393285518849โฌ
- ############################## LUCI #########################################
- - alias: luci Allarme
- initial_state: true
- trigger:
- - platform: state
- entity_id: alarm_control_panel.allarme
- to: 'triggered'
- action:
- - service: light.turn_on
- entity_id: light.luce_cucina
- - service: light.turn_on
- entity_id: light.abat_jour
- - service: light.turn_on
- entity_id: light.luce_ingresso
- - service: switch.turn_on
- entity_id: switch.luce_grande
- - service: switch.turn_on
- entity_id: switch.luce_piccola
- - service: light.turn_on
- entity_id: light.gateway_light_7c49ebb1884a
- ############################## Tasto Cam1 ###################################
- - alias: tasto cam1
- initial_state: true
- trigger:
- - platform: state
- entity_id: input_boolean.cam1
- action:
- service_template: >
- {% if is_state('input_boolean.cam1', 'on') %}
- switch.turn_on
- {% else %}
- switch.turn_off
- {% endif %}
- entity_id: switch.cam1
- ################## DiSATTIVAZIONE ALLARMI #####
- # - alias: MQTT allarme notte off
- # initial_state: true
- # trigger:
- # - platform: mqtt
- # topic: "allarme/disattivazione"
- # condition:
- # condition: template
- # value_template: '{{ "notte" in trigger.payload }}'
- # action:
- # - service: persistent_notification.create
- # data_template:
- # title: "Hassio Snapshot"
- # message: >
- # "Your message goes here " {{ now().strftime('%H:%M') }} -
- # title: "Custom subject"
Add Comment
Please, Sign In to add comment