Using helper value in automation?

Hi everyone

Im fairly new to HA. Im trying to make an automation that modifies the Charging Amp of my EV, based on whether or not my PV is feeding electricity to the grid.

I currently have an automation to start charging if energy is fed to the grid. And then the idea is to have 2 automations to increment/decerement the charging amps based on whether or not power is fed to the grid.

For starters, i just need to make this one work, where i increase the Charging Amps if electricity is still fed to the grid after i start charging

I managed to make a helper-numer-counter that i can modify, and now i want to use the value of that helper as the charging amp. How do i specify this value? Please see screenshot :slight_smile:

Thank you in advance!

For clarification, i initially attempted to specify the id of the helper as the value, but the input box only allows me to type in numeric values :expressionless:

You’re using a Device Action to set an entity’s value. A Device Action doesn’t support templates and you will need to use a template to get the helper’s value. Replace the Device Action with a Service Call (because a Service Call supports templates).

Please post your automation as YAML, not as a screenshot.

Refer to the FAQ about how to present information in a manner that allows us to help you in the most efficient way.

FAQ - Screenshot

FAQ - Format it properly

1 Like

I now have this:

service: number.set_value
metadata: {}
data:
  value: {{ float(states("counter.tesla_desired_amp")) }}
target:
  entity_id: number.rumskibet_charge_current

But when i try to run the step i get the following error:

expected float for dictionary value @ data['value']. Got None

(hence my float conversion)

I tested in the “Developer Tools - Template” where it seems to work as expected (please see screenshot below:

Any pointers? :slight_smile:

service: number.set_value
metadata: {}
data:
  value: >
     {{ states("counter.tesla_desired_amp") | float }}
target:
  entity_id: number.rumskibet_charge_current

issue is that you need to instruct it to interpret the template. can be done via quotes, but I prefer this method.

Also I prefer this other method of casting to float…

1 Like

Thank you so much! Works as expected now :slight_smile:

1 Like