Some automations not working as intended

So I am trying several automations to control components on my aquarium. Many of the automations are working just fine, however, a few of them are not quite working as I intend them to and I know its likely just a case of user error that I just need pointed out to me.

First one is for my aquarium lighting. What I want to happen is the T5 fluorescent lights to turn on every day at noon. Then I made an automation to allow a slider to select how many hours I want them to stay on. The slider automation is working as intended. However the lights do not turn on automatically at noon. I have them set up as two separate automations because that is the only way I know how to do it. So here is what I have:

 - alias: T5 light turn on
  trigger:
    platform: time
    at: '12:00:00'
  action:
    service: switch.turn_on
    entity_id: switch.t5_light
  id: 1ff617a710684dcaa44ac269886b82b3
- alias: T5 Light turn off
  trigger:
    platform: state
    entity_id: switch.t5_light
    to: 'on'
  action:
    - delay: '{{ states.input_number.hours.state | int }}:00:00'
    - service: switch.turn_off
      entity_id: switch.t5_light
  id: 7d2a669fb27a40e4a0506c8534efcee1

The other two automations have a similar problem to each other. The first one I want a pump to turn on four times a day for 30 minutes. What ends up happening is the pump turns on every hour for 30 minutes. Here is that automation:

- alias: Cycle Saltwater Mixing Pump
  trigger:
    platform: time
    minutes: /240
    seconds: 0
  action:
  - service: switch.turn_on
    entity_id: switch.saltwater_mixing_pump
  - delay: 00:30:00
  - service: switch.turn_off
    entity_id: switch.saltwater_mixing_pump
  id: b9d1667320a04bdc95e7b5ed16b30174

Finally, I have a humidity fan I want to turn on four times a day for an hour and also turn on if the humidity goes above 75% then off below 65%. Upon looking at this automation again I realize I don’t even have the high humidity trigger in it. Also this automation tends to turn the fan on for an hour and off for an hour.

- alias: Fish Room Humidity Fan On
  trigger:
    platform: time
    minutes: /240
    seconds: 0
  action:
  - service: switch.turn_on
    entity_id: switch.fish_room_humidity_fan
  - delay: 00:60:00
  - service: switch.turn_off
    entity_id: switch.fish_room_humidity_fan
  - condition: numeric_state
    entity_id: sensor.fish_room_humidity
    below: 65
  id: 5781ac1459aa41608695a6fef85b5585

So any help cleaning up these automations would be very helpful.
Thanks

Your configuration looks good so this points to a small list of things that could be wrong (that you need to fix):

  • Operating system time is set incorrectly.
  • Operating system time zone is set incorrectly.
  • Time zone for home assisntant is set incorrectly (or not set at all).

As for your second problem, switch to:

    platform: time
    hours: '/4'
    minutes: 0
    seconds: 0

I’m pretty sure anything over 60 minutes won’t work correctly. I remember a thread talking about this, @pnbruckner might remember better than I. I debugged into it once but forgot the outcome.

Exactly correct. The '/N' form works by using the modulo operator and testing if the result is zero. And since minutes only goes from 0 to 59, '/240' will be true whenever the minutes value of the current time is 00.

Ah yes, because 240%60 = 0.

Well, strictly speaking, because 0 % 240 == 0. :slight_smile: (Or more explicitly, M % 240 == 0, where M = minute value of 0 through 59, is only true when M is 0, and is false for M values of 1 through 59.)

Timezone is set to New York, just checked that. Also puzzling is that other automations that are set to come on at specific times do trigger.

I’m trying the hours: ‘/4’ now as well. I guess the automation I copied that off of was an older automation. I don’t remember specifically where I got it from.

So a couple other things to check. First, is the automation (that isn’t running at 12:00) turned on? If the automation is off it won’t run. Also, I assumed this was just a copy and paste error, but the first automation in your first post has the first line indented one too many spaces. If that’s the way it is in your actual yaml file, that would explain why it’s not working. Lastly, is it possible input_number.hours is set to zero? If so, the second automation would turn the light off immediately after it was turned on, so you might not be able to tell it went on.

In general looking at the Logbook and/or searching home-assistant.log can help you determine what’s really happening (or not happening.)

The automation is turned on. Just double checked that.

That was a copy and paste error. The yaml looks correct in my file (also there are no config errors when I check config in Hass.io.

The input number is set to 2. It turned off after 2 hours like it should when I manually switched the lights on.

I’ll take a look at the log to see if there was any error or anything like that.

Thanks for the help.

So the automation triggered normally today. Maybe yesterday was the anomaly!