Detection-based-on-temperature.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. blueprint:
  2. name: Detection based on temperature sensors
  3. description: Detect if there is a problem based on the temperature
  4. domain: automation
  5. input:
  6. threshold:
  7. name: Temperature level threshold
  8. description: The temperature thats not normal only posible when there is a problem.
  9. default: 45
  10. selector:
  11. number:
  12. min: 25.0
  13. max: 100.0
  14. unit_of_measurement: "°C"
  15. mode: slider
  16. step: 1.0
  17. include:
  18. name: Included Sensors
  19. description: Temperature sensors to include from detection. Only
  20. entities are supported, devices must be expanded!
  21. default:
  22. entity_id: []
  23. selector:
  24. target:
  25. entity:
  26. device_class: temperature
  27. actions:
  28. name: Actions
  29. description:
  30. Notifications or similar to be run. {{sensors}} is replaced with
  31. the names of sensors with there current exceeded temperature.
  32. selector:
  33. action: {}
  34. source_url: https://gogs.kulmosen.dk/dennis/Temperature-alarm-blueprint
  35. variables:
  36. threshold: !input "threshold"
  37. include: !input "include"
  38. sensors:
  39. "{% set result = namespace(sensors=[]) %} {% for state in states.sensor\
  40. \ | selectattr('attributes.device_class', '==', 'temperature') %}\n {% if 0 <= state.state\
  41. \ | int(-1) > threshold | int and state.entity_id in include.entity_id %}\n\
  42. \ {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state\
  43. \ ~ ' °C)'] %}\n {% endif %}\n{% endfor %} {% for state in states.binary_sensor\
  44. \ | selectattr('attributes.device_class', '==', 'temperature') | selectattr('state',\
  45. \ '==', 'on') %}\n {% if state.entity_id in include.entity_id %}\n {%\
  46. \ set result.sensors = result.sensors + [state.name] %}\n {% endif %}\n{% endfor\
  47. \ %} {{result.sensors|join(', ')}}"
  48. trigger:
  49. - platform: time_pattern
  50. seconds: /30
  51. condition:
  52. - "{{ sensors != '' }}"
  53. action:
  54. - choose: []
  55. default: !input "actions"
  56. mode: single