Automation help needed - HA

mrb13676

Well-Known Member
Joined
Sep 30, 2007
Messages
214
Reaction score
51
I really should be able to do this but it’s just not triggering and I can’t figure out why.

I want an automation to :
  1. Trigger when <75min to load shedding (assessed with a sensor which I have and can be read)
  2. Check if it’s nighttime (defined as 2h prior to sundown until sunrise)
    1. If it’s nighttime - check battery percentage
    2. If <55% then send MQTT message to Victron to charge battery
  3. If it’s daytime (sunrise to 2h prior to sundown)
    1. Check battery percentage
    2. If <40% then send MQTT message to Victron to charge battery.

It isn’t triggering and I’m sure it’s something silly but I’m not seeing it…

YAML:
alias: Draft set inverter
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.eskomcalendar_emmarentia_mins2loadshedding
    for:
      hours: 0
      minutes: 0
      seconds: 0
    value_template: ""
    below: 75
condition:
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: sun
            before: sunrise
            after: sunset
            after_offset: "-02:00:00"
          - condition: numeric_state
            entity_id: sensor.victron_battery_level
            below: 55
      - condition: and
        conditions:
          - condition: sun
            before: sunset
            before_offset: "-02:00:00"
            after: sunrise
          - condition: numeric_state
            entity_id: sensor.victron_battery_level
            below: 40
action:
  - service: modbus.write_register
    data:
      address: 2900
      slave: 100
      hub: victron
      value: 9
  - delay:
      hours: 2
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: modbus.write_register
    data:
      address: 2900
      slave: 100
      hub: victron
      value: 10
mode: single
 
I can't comment on your YAML but you may find the following useful (taken from the HA channel on Discord):

To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:

1) Use Configuration -> Automations to find the automation and then select Run in the three dots menu. If this fails your problem is in the action: section, and details should be found in your log file
2) Use Developer tools -> Services and call automation.trigger on the automation with skip_condition: false. If the first passes but this fails then the problem is in your condition: block
3) Use Developer tools -> States to find the trigger entity, click the name, then change the state (at the top) to something that'll trigger the automation before pushing Set State. If this fails then the problem is with your trigger: section, or the automation is turned off (you can check that in Automations, automations that are turned off will show Disabled)
 
I can't comment on your YAML but you may find the following useful (taken from the HA channel on Discord):

To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:

1) Use Configuration -> Automations to find the automation and then select Run in the three dots menu. If this fails your problem is in the action: section, and details should be found in your log file
2) Use Developer tools -> Services and call automation.trigger on the automation with skip_condition: false. If the first passes but this fails then the problem is in your condition: block
3) Use Developer tools -> States to find the trigger entity, click the name, then change the state (at the top) to something that'll trigger the automation before pushing Set State. If this fails then the problem is with your trigger: section, or the automation is turned off (you can check that in Automations, automations that are turned off will show Disabled)
Thanks. This was helpful - I was able to track the issue to the output form the entity not being a numeric state (despite it looking a lot like a number)….
 
Thanks. This was helpful - I was able to track the issue to the output form the entity not being a numeric state (despite it looking a lot like a number)….
Good job, this also helped me track down some stuff that had me scratching my head for days...
 
Top
Sign up to the MyBroadband newsletter
X