Automation turn off AC when no occupancy longer than 60 minutes

I want to make an automation to turn off Air Conditioning when there is no person in the room longer than 60 minutes.
I use MQTT Tuya zigbee motion sensor - RH3040 and AC based on broadlink wifi card.
There is no roblem with control of AC from Home Assistant, so I only need to create automation.
What trigger should I create for Automation?

I hope you have integrated RG3040 with HA. If not you can follow this guide


You can use the RH3040 state as trigger like this.
trigger:
  - platform: state
    entity_id: binary_sensor.bro_ping
    from: 'on'
    to: 'off'
    for: '01:00:00'

Instead of the my entity_id you should put RH3040 entity id. This looks for 60 minutes off state of that entity.

Do you have a sensor or something that shows when the room is occupied?
Then just trigger on the sensor going to off for 60 minutes.

trigger:
  platform: state
  entity_id: binary_sensor.your_room_occupancy_sensor
  to: 'off'
  for:
    hours: 1

Yes, sensor RH3040 is added to Home Assistant.
I will implement your solutions…
THX

Here it is. Could You look if everyting seems to be correct?

- id: '1612002981776'
  alias: AC OFF when no movement during 1 hour
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.0x5c0272fffecf6474_occupancy
    from: 'on'
    to: 'off'
    for: 01:00:00
    attribute: occupancy
  condition: []
  action:
  - service: climate.turn_off
    data: {}
    entity_id: climate.living_room
  mode: single

You have small corrections.

- id: '1612002981776'
  alias: AC OFF when no movement during 1 hour
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.0x5c0272fffecf6474_occupancy
    to: 'off'
    for: '01:00:00'
  condition: []
  action:
  - service: climate.turn_off
    data: {}
    entity_id: climate.living_room
  mode: single

It does NOT trigger :frowning:
What to check why it is not?

Please share the sceenshot of state of the binary_sensor.0x5c0272fffecf6474_occupancy from the developer console.

Did you reload automations? Double check the entity_id. Is the automation enabled under Developer Tools -> States? Do you get an error under Configuration -> Logs?

I have forgotten to remove it. It seems to work now. But it looks like it started only one time.

It will only work when the binary sensor is off for 1 hour without any change.

Seems to by configured properly now and it works. THX for help:)

1 Like