Skip to content

Environment

Jenx edited this page Mar 3, 2022 · 1 revision

The environment monitoring automations are primarily Gas, Smoke and Heat sensors and alarms. I have installed close to the gas heating boiler a carbon monoxide sensor from Heimann, three smoke sensors from Heimann and tied a number of environment monitors from Aqara together in heat and humidity monitoring automations.

AUTOMATIONS

CO leak Utility

This device measures carbon monoxide (CO) levels and triggers an audible alarm if they rise above a threshold value. In addition they are zigbee enabled and tied into my Home Assistant system. The triggering of the audible alarm also triggers an announcement to the SONOS system, messages to Home Assistant notifications, an email and to our mobile phones. The reason for the overkill is 1) I wanted to make sure someone was aware of the dangerous levels of toxic CO and 2) experimenting with the various forms of notification available to me, which were relatively new to me at the time.

`trigger:
- platform: state
  entity_id: binary_sensor.boiler_co
  to: "on"
 action:
 # message the webpage ####################
- service: persistent_notification.create
  data:
    message: "Carbon Monoxide (CO) has been detected in the Utility"
    title: "Urgent - Carbon Monoxide Detected"
 # Message our email addresses  and announce #########
- service: notify.alarm_email
  data:
      title: 'CO leak detected'
      message: 'Carbon Monoxide has been detected near the boiler'
- service: tts.cloud_say
  data:
    entity_id: media_player.master_bedroom_sonos
    message: Warning, carbon monoxide has been detected near the boiler, please investigate CO leak
    options:
      gender: male
    language: en-GB
- service: notify.mobile_app_one_9
  data_template:
    title: "Rick, Carbon Monoxide has been detected near the boiler {{ trigger.to_state.attributes.friendly_name }} has been triggered"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max
- delay: 2
- service: notify.mobile_app_one_8
  data_template:
    title: "Debs, Carbon Monoxide has been detected near the boiler {{ trigger.to_state.attributes.friendly_name }} has been triggered"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max`

Humidity

An early automation was a humidity monitor in our utility room which houses our washing machine and dryer. The automation provides a simple notification if the humidity levels rise to 100%.

`trigger:
- platform: numeric_state
  entity_id: sensor.utility_multi_humidity
  above: 90
  for: "00:30:00"
 action:
- service: notify.mobile_app_one_9
  data:
    title: Humidity is very high in the Utility, suggest turn on fan
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max
- delay: 2
- service: notify.mobile_app_one_8
  data:
    title: Humidity is very high in the Utility, suggest turn on fan
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max`

Smoke Sensor trigger at night

This is the first of our automations for smoke detection and specifically responds to a trigger at night when the household is likely in bed. The trigger is one of the three smoke sensors detecting smoke. Its only triggered if the family is at home and after sunset. The automation sends a notification to the Home Assistant frontend and also announcements on our phones. As a safety precaution the automation also turns on all lights.

`  trigger:
- platform: state
  entity_id: 
    - binary_sensor.hall_smoke
    - binary_sensor.kitchen_smoke
    - binary_sensor.landing_smoke
  to: "on"
condition:
- condition: state
  entity_id: group.family
  state: 'home' 
- condition: sun
  after: sunset
  before: sunrise
action:
- service: light.turn_on
  entity_id: group.all_lights
 # message the phones ####################
- service: notify.mobile_app_one_9
  data_template:
    title: "Rick, the {{ trigger.to_state.attributes.friendly_name }} has been triggered"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max
- delay: 2
- service: notify.mobile_app_one_8
  data_template:
    title: "Debs, the {{ trigger.to_state.attributes.friendly_name }} has been triggered"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max`

Smoke sensor trigger while away

This has the same trigger, one of the smoke sensors, but the condition this time is that the family are away from home. Again a notification is sent to Home Assistant and announcements are made to our mobile phones. No lights are turned on.

`trigger:
- platform: state
  entity_id: 
    - binary_sensor.hall_smoke
    - binary_sensor.kitchen_smoke
    - binary_sensor.landing_smoke
  to: "on"
condition:
- condition: state
  entity_id: group.family
  state: 'not_home' 
action:
# message the webpage ####################
- service: persistent_notification.create
  data:
    message: "Smoked detected at Home"
    title: "Urgent - Smoke Detected"
# Message our email addresses  and announce #########
- service: notify.alarm_email
  data:
      title: 'Smoke detected'
      message: 'The Smoke Detector has triggered'
- service: notify.mobile_app_one_9
  data_template:
    title: "Rick, the {{ trigger.to_state.attributes.friendly_name }} has been triggered"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max
- service: notify.mobile_app_one_8
  data_template:
    title: "Debs, the {{ trigger.to_state.attributes.friendly_name }} has been triggered"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max`

Heat Alarm

In the unlikely event of a fire which does not trigger a smoke alarm, or a malfunction in the heating system this automation is triggered by a rise in temperature above 40 C. It sends a notification to the Home Assistant front end, announcements to our mobile phones and announcements on the SONOS system, it then repeats the announcement after a delay of 5 seconds to ensure the announcement has been heard.

`trigger:
- platform: numeric_state
  entity_id: 
    - sensor.bathroom_multi_temperature
    - sensor.bedroom_multi_temperature
    - sensor.landing_motion_temperature
    - sensor.lounge_multi_temperature
    - sensor.lounge_window_left_temperature
    # - sensor.syn01_temperature
    - sensor.thermostat_3_current_temperature
    - sensor.utility_multi_temperature
    - sensor.utility_toilet_temperature
  above: 40
action:
# message the webpage ####################
- service: persistent_notification.create
  data:
    message: "Heat detected at Home"
    title: "Urgent - Heat Detected"
# Message our email addresses  and announce #########
- service: notify.alarm_email
  data:
      title: 'Heat detected'
      message: 'Heat Detector has triggered'
- service: notify.mobile_app_one_9
  data_template:
    title: "Rick, High Temperature has been detected by {{ trigger.to_state.attributes.friendly_name }} please investigate"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max
- service: notify.mobile_app_one_8
  data_template:
    title: "Debs, High Temperature has been detected by {{ trigger.to_state.attributes.friendly_name }} please investigate"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max  
- service: sonos.join
  data:
    master: media_player.living_room_sonos
  entity_id:
    - media_player.kitchen_sonos
    - media_player.dining_room_sonos
    - media_player.master_bedroom_sonos
- service: sonos.snapshot
  entity_id: media_player.living_room_sonos
- service: media_player.volume_set
  entity_id:
    - media_player.living_room_sonos
    - media_player.kitchen_sonos
    - media_player.dining_room_sonos
    - media_player.master_bedroom_sonos
  data:
    volume_level: 0.60
- service: tts.cloud_say
  entity_id: media_player.living_room_sonos
  data:
    message: Heat above 40c has been detected please investigate
    options:
      gender: female
    language: en-GB
- delay: 5
- service: tts.cloud_say
  entity_id: media_player.living_room_sonos
  data:
    message: I repeat, Heat above 50c has been detected please investigate
    options:
      gender: female
    language: en-GB
- delay: 3
- service: sonos.restore
  entity_id: media_player.living_room_sonos
- service: sonos.unjoin
  data:
    entity_id:
    - media_player.living_room_sonos
    - media_player.kitchen_sonos
    - media_player.dining_room_sonos
    - media_player.master_bedroom_sonos`

ROC Alarm

The ROC alarm takes advantage of the temperature sensors from Aqara deployed around the home. The intention is to increase the number of these along with radiator smart valves (TRV).

A template sensor calculates the rate of change in temperature over a period of 30 minutes and if any sensor shows a rate of change greater than 10 degrees per hour this triggers the automation. An example of the ROC sensor is shown below, each temperature sensor included has its own ROC template sensor in the sensors.yaml file.

`- platform: derivative
   source: sensor.lounge_multi_temperature
   name: Lounge ROC Temperature
   round: 1
   unit_time: h
   time_window: "00:30:00"

`

The 10 degrees is based on observation for a few days of the template sensor to determine what is the maximum usual rate of change as the house heats up when the central heating turns on. It may need adjustment when the summer arrives as this was set up during winter. The template sensor has proved to be a little unreliable, with at least two occasions in a month where false alarms have occurred.

`trigger:
- platform: numeric_state
  entity_id: 
    - sensor.lounge_roc_temperature
    - sensor.bedroom_roc_temperature
    - sensor.utility_roc_temperature
    - sensor.bathroom_roc_temperature
  above: 10 # Normal heating should not exceed 5 - 6c / hr
  for:
    minutes: 2
 action:
 # set persistent switch ####################
- service: input_boolean.turn_on
  entity_id: input_boolean.roc
 # Message our email addresses  and announce #########
- service: notify.alarm_email
  data:
      title: 'Rapid temperature increase'
      message: 'Temperature is increasing too fast'
- service: notify.mobile_app_one_9
  data_template:
    title: "Rick, Rapid rise in temperature detected in {{ trigger.to_state.attributes.friendly_name }} please investigate"
    message: TTS
    data:
      ttl: 0
      priority: high
      channel: alarm_stream_max`

SCRIPTS

None

FUTURE

Each of these automations has been put together at different times, some rationalisation of the code is in order, use of conditional flows can also simplify the automations and a clear strategy on the different communication channels will also help to simplify and standardise the automations.

For example, when to use notifications, when to announce on SONOS, how this works with announcements to mobile phones etc. Are there alternative communication channels that would be more effective?

Moving some of the code for handling communication to devices (mobile and SONOS) which are repeated frequently to a script that can be called would greatly simplify the complexity of the automations.

The current smoke sensor in the kitchen is often triggered when cooking, we may move this out of the kitchen and replace with a couple of temperature sensors as rely on the ROC template for sensing fire in the kitchen. A smoke sensor is in the adjacent room in case of smoke escaping from the kitchen.

OTHER