Please help me Automation not triggered

Hi

Maybe someone can help me find out why this automation doesn’t do what I want it to do.

What I want:

Check if humidity is above 50% for 1min and if between 10-16h start the dehumidifie for 1h.
If during that period the humidity is still above 50% reset the 1h timer, so it doesn’t trigger on/off, as the compressor always need some time to restart which i want to eliminate.

alias: 50% Luftfeuchtigkeit
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.aqara_waschkueche_humidity
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: '50'
    attribute: humidity
condition:
  - condition: time
    after: '10:00:00'
    before: '16:00:00'
action:
  - service: switch.turn_on
    data: {}
    target:
      device_id: 01cc8cfdcd23e9e8aee56be96099fed5
  - delay:
      hours: 1
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    data: {}
    target:
      device_id: 01cc8cfdcd23e9e8aee56be96099fed5
mode: restart

I tried TRIGGER = state as well, but it won’t help. I want the automation to continously check humidity, and not be triggered only if humidity is/was above 50%.

What does the entity look like in developer tools?

At a guess (which is why Hellis81 is asking), the humidity sensor shows the measured humidity in its state, not in an attribute. If I’m right, you need to remove the attribute: humidity line in your automation, and reload.

This automation will only trigger if the humidity transitions from below 50% to above 50% then stays there for 1 minute. It won’t do the timer reset thing that you’re hoping it will. Let’s get the first bit working, then we can have a look at that.

image

But how would I make it watch the number all the time? It may be an issue only now as it’s harder to trace, but may be worthful to know for later automations.

You need to remove the line with attribute as stated earlier.

What could happen is that the humidity goes above 50 before 10:00.
If you add above 50 humidity as condition also, then add time trigger 10:00.

This means if the time is 10:00 and it’s above 50% then it will turn on.

I don’t think it’s a good idea to just have it running for an hour.
Have it on until it’s below say 40% instead.

But doesn’t the dehumidifier already have a logic like this built in? Most do

1 Like

The attribute line is already removed. Sorry. Didn’t mention that.

I let it run 1h for a reason. I don’t need EXACTLY 50% (as this changes all the time anyway). The humidifier has a “setpoint = 50%” as well, but what this makes is turning the compressor on/off all the time, which causes power surge which my battery inverter has troubles with. I like 500W power usage straight for one hour minimum if it starts at 10:00. And if at 10:13 humidity is still >50% then it should run til 11:13. And so on. It will start to go up after that anyway. But eventually it will be at 42% humidity at 11:13, so it will start at like 13:00 again, and not turn on again at 11:14.

So what’s the correct trigger for continous monitoring a value? Or should i go node-red route?

Are you sure about this?
Our does occasionally start up with just the fan to move the air around in the room and get a better reading, but it doesn’t start the compressor.

So you want it to start every full hour if it’s above 50%?
I generally find these automations dumb, but a time pattern trigger of every hour and condition > 50%.

Not sure I understand the logic with this part here.

It started at 10:00, and because it was above 50% at 10:13, then it should continue to 11:13?
So what if it’s still above 50% at 10:20?
This part just doesn’t make sense to me.

I have a suggestion.
What if we do this time pattern trigger every hour, and if the humidity is above 50% then we start the dehumidifier.
If it’s below then we turn it off.
That means it can at a minimum run for 1 hour and it will only turn off if it’s below 50%

No need for node-red.

Automation 1: Trigger on humidity going above 50% for one minute, start the dehumidifier.
Automation 2: Trigger on humidity being below 50% for one hour, turn off the dehumidifier.

Does that do what you want?

No it doesn’t.

I want it to check if humidity is above 50% between 10:00-16:00, as this is the time my solar system produces power most certainly.
Second: If it starts it should run for 1h at least and not cylce on/off all the time. If during this 1h the humidity is measured again, and it’s still over 50% it should run for 1h more.

Example:

09:55 60% → nothing
10:01 60% → on for one hour till 11:01
10:05 59% → still over 50%, add one hour. On until 11:05
11:05 49% → off
11:40 51% → on until 12:40

Should be easy doable once i find out how I can run automations on “state_changed” like in node-red.

image

State changes → sensor value is checked against a given value and that’s it.

No it’s not the fan. It’s the compressor as it toggle between zero W and full power.

I don’t want it to start every full hour. I want to CONSTANTLY monitor humiditiy changes and if humidity is above 50% it should turn on the humidifier for one hour. And if during this hour it still is above 50% it should add one more hour from time of measurement.

This sounds like what Troon suggested

Sorry. Maybe I didn’t read it correctly what @Troon wrote. Yes. This could work.
But I hate having to have two automations to do one thing. I’d really like to get my brain understand how this can be done in one automation.
And still it does not solve the issue if humidity is like 60% and NEVER goes below 50%. In that case it will never be triggered. Correct?

With a time trigger at 10, then it will.

Sorry, could you elaborate on what you mean by that? What would that look like?

Something like this I think.

alias: 50% Luftfeuchtigkeit
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.aqara_waschkueche_humidity
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: '50'
    id: 'on'

  - platform: time
    at: '10:00:00'
    id: time

  - platform: numeric_state
    entity_id: sensor.aqara_waschkueche_humidity
    for:
      hours: 1
      minutes: 0
      seconds: 0
    id: 'off'
    below: '50'

condition: []

action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'on'
          - condition: time
            after: '10:00:00'
            before: '16:00:00'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5

      - conditions:
          - condition: trigger
            id: 'off'
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5

      - conditions:
          - condition: trigger
            id: time
          - condition: numeric_state
            entity_id: sensor.aqara_waschkueche_humidity
            above: '50'
        sequence: 
          - service: switch.turn_on
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5
    default: []

One little issue with this is that it could fail if you restart HA at 9:59:59 or a few seconds before this.
We could add a homeassistat start event as a trigger with condition of time and humidity.

alias: 50% Luftfeuchtigkeit
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.aqara_waschkueche_humidity
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: '50'
    id: 'on'

  - platform: time
    at: '10:00:00'
    id: time

  - platform: numeric_state
    entity_id: sensor.aqara_waschkueche_humidity
    for:
      hours: 1
      minutes: 0
      seconds: 0
    id: 'off'
    below: '50'

  - platform: event
    event_type: homeassistant_start
    id: start

condition: []

action:
  - choose:
      - conditions:
          - condition: trigger
            id: 'on'
          - condition: time
            after: '10:00:00'
            before: '16:00:00'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5

      - conditions:
          - condition: trigger
            id: 'off'
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5

      - conditions:
          - condition: trigger
            id: time
          - condition: numeric_state
            entity_id: sensor.aqara_waschkueche_humidity
            above: '50'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5

      - conditions:
          - condition: trigger
            id: start
          - condition: time
            after: '10:00:00'
            before: '16:00:00'
          - condition: numeric_state
            entity_id: sensor.aqara_waschkueche_humidity
            above: '50'
        sequence: 
          - service: switch.turn_on
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5
    default: []

OMG. Thanks. And now you completely lost me :wink: I will need 2h to understand what this automation does :slight_smile:

It’s not very hard.
Just look at the id: and find the action for this id in the actions part.

So for example:

  - platform: numeric_state
    entity_id: sensor.aqara_waschkueche_humidity
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: '50'
    id: 'on'

is this action:

      - conditions:
          - condition: trigger
            id: 'on'
          - condition: time
            after: '10:00:00'
            before: '16:00:00'
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              device_id: 01cc8cfdcd23e9e8aee56be96099fed5

Sorry for the delayed response.

This is part of the game of writing decent automations — trying to raise yourself above the level of the first idea you have as to how it should work and look instead at what you want it to do, freeing yourself to consider simpler, more efficient implementations. My previous post does indeed (with the exception of the 10:00 complication) sum up what you want, but isn’t how you initially conceived it.

As a basic rule, if you find yourself checking something “often” rather than waiting for something to happen, you’re probably doing it wrong.

I think the solution @Hellis81 gave wraps it up well. I’d probably implement it as a separate “on” and “off” automation as per my description, with the 10:00 and restart triggers added as appropriate — but that’s just personal choice.

Good luck, and if @Hellis81’s solution works for you, please mark it as the Solution (the tick box).