Automation/ Turn off inverter at specific voltage and output

Hey everybody,

I’m new to the whole universe of HA. I mastered some automation already by myself but this one is quite challenging. In this I use templates and I always get problems with the request of the state of the battery output power. "Message malformed: template value should be a string for dictionary value @ data[‘action’][0][‘if’][0][‘conditions’][3][‘value_template’]"

So I don’t know what exactly is wrong and in the developer tools, the expression is always functioning. I will post the code below with some comments on what it actually should do. I hope you can help me

alias: Deye Ein-/Ausschalten Low Batt
description: >-
  Turn off the Inverter when the Voltage is under 51,3V and the battery output power is below 200W. First, it has to turn off the beep and then the Inverter itself
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.deye_battery_voltage
    below: 51.3
    id: Voltage_Low
  - platform: time
    at: "07:00:00"
    id: DeyePower_On
    
condition: null
action:
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id:
              - Voltage_Low
          - condition: time
            after: "18:00:00"
            before: "7:00:00"
          - condition: template
            value_template: "{{ now().month in [1,2,3,10,11,12] }}"      # this works actually fine
          - condition: template
            value_template: >-
              {{states("sensor.deye_battery_output_power") | float(0) < 200 }}     # Here is the problem I would like to check if the current output power is under 200W and then return true 
    then:
      - service: input_boolean.turn_off                      # First turn off the warning noises, then the inverter. I know  a delay is not accurate...
        data: {}
        target:
          entity_id: input_boolean.beep
      - delay: "00:01"
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.deye_hautptschalter
    else: []
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id: DeyePower_Off
          - condition: template
            value_template: "{{ now().month in [1,2,3,10,11,12] }}"
          - condition: template
              value_template: >-
                {{is_state("switch.deye_power_on", "off") }}  # Should check whether the inverter is off then return true. 
    then:
      - service: input_boolean.turn_on                       # First turn on Inverter then turn on the warning noises 
        data: {}
        target:
          entity_id: input_boolean.deye_hautptschalter
      - delay: "00:01"
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.beep
    else: []
mode: single

Thanks in advance!

Okay i solved it now. Code is attached:

alias: Test V2
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.deye_battery_voltage
    below: 51.3
    id: Voltage_Low
  - platform: time
    at: "07:30:00"
    id: DeyePower_Off
condition: []
action:
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id: Voltage_Low
          - condition: time
            after: "18:00:00"
            before: "7:00:00"
          - condition: template
            value_template: |
              {{states("sensor.deye_battery_output_power") | float(0) < 200 }} 
          - condition: template
            value_template: |
              {{ now().month in [1,2,3,10,11,12] }}
    then:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.beep
      - delay: "00:01"
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.deye_hautptschalter
    else: []
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id: DeyePower_Off
          - condition: template
            value_template: |
              {{is_state("switch.deye_power_on", "on") }} 
          - condition: template
            value_template: |
              {{ now().month in [1,2,3,10,11,12] }}
    then:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.deye_hautptschalter
      - delay: "00:01"
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.beep
    else: []
mode: single

1 Like