Advertisement
calas

Jammer

Apr 30th, 2022
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.56 KB | None | 0 0
  1. homeassistant:
  2.   customize:
  3.     package.node_anchors:
  4.       customize: &customize
  5.         package: 'Package Anti Jammer'
  6.         version: 'v1.0 29/04/2022'
  7.         author: 'Calas'
  8.  
  9.       expose: &expose
  10.         <<: *customize
  11.         haaska_hidden: false
  12.         homebridge_hidden: false
  13.  
  14. ################################################################################
  15. ##                  Input Boolean
  16. ###################################################
  17. input_boolean:
  18.   anti_jammer_controllo:
  19.     name: Controllo Anti Jammer
  20.     icon: mdi:wifi-strength-alert-outline
  21.  
  22. ################################################################################
  23. ##                  Input UMBER
  24. ###################################################
  25. input_number:
  26.   anti_jammer_high_availability_vote:
  27.     name: Anti Jammer HA vote soglia
  28.     icon: mdi:counter
  29.     min: 1
  30.     max: 5
  31.     step: 1
  32.     unit_of_measurement: 'Voti'
  33.  
  34. ################################################################################
  35. ##                  Counter
  36. ###################################################
  37. counter:
  38.   anti_jammer_high_availability_vote:
  39.     initial: 0
  40.     step: 1
  41.  
  42. ################################################################################
  43. ##                  Script
  44. ###################################################
  45. script:
  46.   anti_jammer_counter_increment:
  47.     sequence:
  48.       - service: counter.increment
  49.         target:
  50.           entity_id: counter.anti_jammer_high_availability_vote
  51.  
  52.   anti_jammer_counter_decrement:
  53.     sequence:
  54.       - service: counter.decrement
  55.         target:
  56.           entity_id: counter.anti_jammer_high_availability_vote
  57.  
  58. ################################################################################
  59. ##                  Automations
  60. ###################################################
  61. automation:
  62.   - alias: Anti Jammer counter_startup
  63.     id: f2b626dbdb867435c96e14acf3657c81
  64.     trigger:
  65.       - platform: homeassistant
  66.         event: start
  67.     action:
  68.       - service: counter.reset
  69.         target:
  70.           entity_id: counter.anti_jammer_high_availability_vote
  71.       - delay: '00:00:30'
  72.       - service_template: >
  73.          {% if is_state('binary_sensor.antifurto_stato', 'on') %}
  74.             script.anti_jammer_counter_increment
  75.           {% endif %}
  76.       - service_template: >
  77.          {% if is_state('binary_sensor.abat_jour_stato', 'on') %}
  78.             script.anti_jammer_counter_increment
  79.           {% endif %}
  80.       - service_template: >
  81.          {% if is_state('binary_sensor.stufetta_stato_esp', 'on') %}
  82.             script.anti_jammer_counter_increment
  83.           {% endif %}
  84.  
  85.  
  86.   - alias: Anti Jammer antifurto_stato
  87.     id: 38aa711de0c498124ba4ffb3559682d8
  88.     trigger:
  89.       - platform: state
  90.         entity_id: binary_sensor.antifurto_stato
  91.     action:
  92.       - service_template: >
  93.          {% if trigger.to_state.state == 'on' %}
  94.             script.anti_jammer_counter_increment
  95.           {% elif trigger.to_state.state == 'off' %}
  96.             script.anti_jammer_counter_decrement
  97.           {% endif %}
  98.  
  99.   - alias: Anti Jammer abat_jour_stato
  100.     id: 261d3b642198aab1864b610dc41aa502
  101.     trigger:
  102.       - platform: state
  103.         entity_id: binary_sensor.abat_jour_stato
  104.     action:
  105.       - service_template: >
  106.          {% if trigger.to_state.state == 'on' %}
  107.             script.anti_jammer_counter_increment
  108.           {% elif trigger.to_state.state == 'off' %}
  109.             script.anti_jammer_counter_decrement
  110.           {% endif %}
  111.  
  112.   - alias: aAnti Jammer stufetta_stato_esp
  113.     id: 261d3b642198aab1864b610dc41aa502
  114.     trigger:
  115.       - platform: state
  116.         entity_id: binary_sensor.stufetta_stato_esp
  117.     action:
  118.       - service_template: >
  119.          {% if trigger.to_state.state == 'on' %}
  120.             script.anti_jammer_counter_increment
  121.           {% elif trigger.to_state.state == 'off' %}
  122.             script.anti_jammer_counter_decrement
  123.           {% endif %}
  124.  
  125.   - alias: Anti Jammer norifica
  126.     id: de16b9b9c9d26f2523c8e12e1f2611c2
  127.     trigger:
  128.       - platform: tempalte
  129.         value_template: "{{ states('counter.anti_jammer_high_availability_vote') | int < states('input_number.anti_jammer_high_availability_vote') | int }}"
  130.         for:
  131.           seconds: 60
  132.     condition:
  133.       condition: state
  134.       entity_id: input_boolean.anti_jammer_controllo
  135.       state: 'on'
  136.     action:
  137.       - service: !secret notifiche_francesco
  138.         data:
  139.           title: '*ATTENZIONE*'
  140.           message: 'Possibile impiego di jammer - {{now().strftime("%d.%m.%Y - %H:%M:%S")}}'
  141.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement