#Use entity state as input on action

1 messages · Page 1 of 1 (latest)

dire roost
#

Hello,
I have a custom action that takes a number in our custom component defined as:

  name: Battery Charge
  description: Set the battery to charge (will force a charge either from the solar panels and then the grid)
  fields:
    amount_to_charge:
      name: Kw to charge
      required: true
      default: 0
      selector:
        number:
          min: 0
          max: 13```
In our services.yaml.
When using this in an automation I get a slider to set the input, which works okay.

Our goal instead is to have an entity as input for this, I tried it by having my automation appear like this:
```alias: zonnedorpen charge from grid
description: ""
triggers: []
conditions: []
actions:
  - repeat:
      sequence:
        - action: zonnedorpen_controller.battery_to_charge
          data:
            amount_to_charge: {{states('charge_powerref') | float}}
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
      while:
        - condition: state
          entity_id: zonnedorpen.grid_automation_bool
          state: "True"

However I keep getting errors like the attached screenshot.
Am I grabbing the state incorrectly?
I used the following as an example:
https://community.home-assistant.io/t/using-a-state-attribute-in-an-automation-action/428269

The actual state looks like the second attached picture.

#

Use entity state as input on action