2024.5.1 Breaks automation

I had automation turning on and of a shelly plug which worked just fine. HOwever after the upgrade to the 2024.5.1, the automation doe snot keep switching off as it should.

The highlighted period should not be on. THe trigger on automation does not kick in after 6 PM and the switch of checks every minute after that and switches it off.

So obviously this is not happening. ANd it only started after the upgrade. Is anyone seeing any issues similar to mine?

There’s your problem.

Too much female deer mucus. :rofl:

But seriously…

Can you control the switch manually from Home Assistant?

Not much else we can recommend without seeing your automation config.

4 Likes

Yes, I can control the switch. The Shelly talks fine.

Here you go: Turning ON

alias: Zapni Bojer
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: /1
condition:
  - condition: or
    conditions:
      - condition: time
        after: "06:00:00"
        before: "06:57:30"
        weekday:
          - sun
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
        enabled: false
      - condition: time
        after: "11:00:00"
        before: "17:58:00"
        weekday:
          - sun
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.192_168_30_211
        state: "on"
      - condition: state
        entity_id: binary_sensor.hdo
        state: "on"
      - condition: state
        entity_id: switch.shellyplusplug_bojler_switch_0
        state: "off"
action:
  - type: turn_on
    device_id: 5734ed670dc5462c87b3e958583c9d75
    entity_id: 65ee5a8ec918cd6b75632c8a62739713
    domain: switch
  - service: input_datetime.set_datetime
    metadata: {}
    data:
      datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
    target:
      entity_id: input_datetime.boiler_last_time_on
mode: single

And Turning OFF:

alias: Vypni Bojler
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: /1
condition:
  - condition: or
    conditions:
      - condition: time
        after: "06:59:30"
        weekday:
          - sun
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
        before: "10:59:30"
        enabled: false
      - condition: time
        after: "17:58:00"
        weekday:
          - sun
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
        before: "10:58:00"
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.192_168_30_211
        state: "on"
      - condition: state
        entity_id: switch.shellyplusplug_bojler_switch_0
        state: "on"
action:
  - type: turn_off
    device_id: 5734ed670dc5462c87b3e958583c9d75
    entity_id: 65ee5a8ec918cd6b75632c8a62739713
    domain: switch
mode: single

EDIT: And the automation keeps turning it on. I just switched it on manually and at next minute, it flipped it back on.

EDIT 1: And I just pushed latest 2024.5.2 version. So will see later on if it switches off.

So what do the automation traces show?

Also that is the worst possible way you could do this. There is absolutely no need for this:

Here’s how you would do it correctly:

alias: Zapni Bojer
description: ""
trigger:
  - platform: time
    at: "06:00:00"
  - platform: time
    at: "11:00:00"
  - platform: state
    entity_id: binary_sensor.192_168_30_211
    from: "off"
    to: "on"
  - platform: state
    entity_id: binary_sensor.hdo
    from: "off"
    to: "on"
  - platform: state
    entity_id: switch.shellyplusplug_bojler_switch_0
    from: "on"
    to: "off"
condition:
  - condition: or
    conditions:
      - condition: time
        after: "06:00:00"
        before: "06:57:30"
      - condition: time
        after: "11:00:00"
        before: "17:58:00"
  - condition: state
    entity_id: binary_sensor.192_168_30_211
    state: "on"
  - condition: state
    entity_id: binary_sensor.hdo
    state: "on"
  - condition: state
    entity_id: switch.shellyplusplug_bojler_switch_0
    state: "off"
action:
  - service: switch.turn_on
    target:
      entity_id: switch.shellyplusplug_bojler_switch_0
  - service: input_datetime.set_datetime
    metadata: {}
    data:
      datetime: "{{ now() }}"
    target:
      entity_id: input_datetime.boiler_last_time_on
mode: single

Same for the off automation.

85% sure that switch.shellyplusplug_bojler_switch_0 is 65ee5a8ec918cd6b75632c8a62739713

1 Like

Ok I changed it.

Traces show correct. When checking day or so ago, it actually did not trigger ON outside of the range and was triggering OFF when it should.

I’ve just checked it now and while HA showed ON, shelly was OFF. But there are no errors shown on communication side. Turning it OFF via HA, it flips back on - and no change on SHelly.

So i flipped it ON/OFF on shelly and suddenly it reflected in HA. Now When turning ON/OFF in HA< it also reflects on shelly. It is strange.

I will dig through this hopefully little bit more today as I will have time.
And I will also check the automation suggested.

THe reason for the minute trigger was to make sure it turns on anaytime within the interval in case there was for example power outage or it was switched of by someone/something. But I’ll check what you suggested. Thanks for now.

So I’ve updated the automation rules using your suggestion (slightly adjusting). That is good.

Something I did not say before is that during the HDO off, power to shelly is lost. So the device goes offline. THat can be seen on the 192.168.30.211 IP address as it gets disconnected.

WHat I observed is that HA can turn the device on, but it unable to turn it off. I have set switch off automation trigget at 6:05 PM and that run (see trace), but shelly did not get it.

THe only way that seems to work to fix it to initiate toggle on shelly which updates HA and then HA works.

I am thinking whether it is related to the shelly loosing power and then when coming up, it is not updated which then does something on HA side that fails to talk to it. I will try to adjust the automation to switch off before HDO goes off, so the HA has always right state.