WEMO Maker to turn on/off with delay

Hi guys & girls!

I’m trying to reduce the use of energy by my short term tenants specifically the abuse of air conditioners, and I was about to buy a ON/OFF TIME DELAY RELAY to hook up to my WEMO Maker until I found Home Assistant, and it blew up my mind!!

So… my Maker’s sensor is hooked to 4 magnetic switches (entrance door: 1x NC for closing and 1x NO for the deadbolt, balcony sliding doors: 2x NC).

What I need is that the air con only work if doors are closed, and the NO on the deadbolt will determine presence (which can only be locked from outside):

when switch.wemo_maker.attributes.sensor TURNS OFF switch.wemo_maker TURNS OFF with DELAY=5minutes
when switch.wemo_maker.attributes.sensor TURNS ON switch.wemo_maker TURNS ON with DELAY=2minutes

And perhaps it should be an automation, so I could turn it off if sh*t hit the fan… or air conditioner :stuck_out_tongue:

I’m new here but I’ve tried many different approaches, mashing up codes but can get it to work, achieving something but got errors whenever I tried to add delay and changes on the sensors are visible by HA but doesn’t affect WEMO… the last one is:

  # WEMO Maker
  aircon_state:
    value_template: >-
      {%if states.switch.wemo_maker.attributes.sensor_state == 'on' %}
        on
      {%elif states.switch.wemo_maker.attributes.sensor_state == 'off' %}
        off
      {% else %}
        unknown
      {% endif %}
    friendly_name: 'Air Conditioners State'
  - platform: template
    switches:
      blind:
        friendly_name: 'WEMO sensor'
        value_template: "{{ is_state_attr('switch.wemo_maker', 'sensor_state', 'on') }}"
        turn_on:
          service: switch.turn_on
          entity_id: switch.wemo_maker
        turn_off:
          service: switch.turn_off
          entity_id: switch.wemo_maker

Also tried automation:

- alias: Turn on air conditioners 2 minutes after every doors are closed.
  trigger:
    platform: state
    entity_id: sensor.aircon_state
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: switch.wemo_maker

- alias: Turn off air conditioners 5 minutes after a door opened.
  trigger:
    platform: state
    entity_id: sensor.aircon_state
    to: 'off'
  action:
    service: homeassistant.turn_off
    entity_id: switch.wemo_maker

The template switch probably isn’t useful to you. It doesn’t trigger based on the value template - just uses that to set the switch state - which I don’t think is what you need, so I think automation is the way to go

Is your aircon_state sensor working correctly (ie displaying in the GUI and changing state when you expect)? I assume that it’s in the sensor rather than binary_sensor section of your config?

Assuming the that’s the case, then we just need to get your automations working. To me they look correct. The only difference to mine that I can see is that I use switch.turn_on - which I think is the same, but might be worth trying.

Do you see any error in the log when you change the aircon_state sensor? Do you see the automation triggering in the logbook?

If not you can remove the to: which should result in the automations triggering with any state change for that device. Not what you want - but might help debug.

Once it works you should just need to add for: to get the timing you want.

1 Like

Hi gregd, thanks for your time!

I don’t see any errors and I do see sensor changes in the server.
Funny thing is, if I hit the trigger button in the automation window it works, it changes the switch.
And inside the log book my sensor also shows up.

for doesn’t work unless I build an IF function… Something like: {%if states.switch.wemo_maker.attributes.sensor_state == 'on' for: '0:05:00' %} that’s why I was looking for delay, because I need the action to happen only after that given time.

It’s good to know Automation is the way to go, at least I can exclude the other possibilities!

Just in case it helps I have a delay that opens my blinds when my clock radio has been on for 7 mins in the morning.

the automation is

- alias: 'Open blind'
  trigger:
    platform: state
    entity_id: switch.hi_fi_sources
    to: 'on'
    for:
      minutes: 7
  condition:
    condition: and
    conditions: 
    - condition: time
      after: '06:45:00'
      before: '09:45:00'
    - condition: state
      entity_id: cover.blind_104
      state: "closed"
  action:
    - service: cover.open_cover
      data:
        entity_id: cover.blind_104
    - delay: 00:01:00
    - condition: state
      entity_id: sun.sun
      state: "below_horizon"
    - service: light.turn_on
      data:
        entity_id: light.bookcase_uplighters_15

Thx! That is a neat automation! :slight_smile: I think I can take bits of yours… I will post an update later!