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…

2 Likes

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

1 Like

Hi, i’m feeling helpless…

I had this automation by the visual editor:

device_id: 937f5dffb4c3c3e5d42b203dc1d97e26 <---- This is my Feyree Charger
domain: number
entity_id: 0a9c16a80b550d87c23834ba680d3a2c   <---- This is my "Charging Ampere"
type: set_value
value: 1

This automation was made by the visual editor. Now i want to insert the value of an helper, which is incrementing/decrementing by the charging power of my solarsystem, so 8 → 10 → 12 → 14 → 16 and, on afternoon or clouds, back to 8 (and later the charger is turned of).

So i tried this:

device_id: 937f5dffb4c3c3e5d42b203dc1d97e26
domain: number
entity_id: 0a9c16a80b550d87c23834ba680d3a2c
type: set_value
value: {{ states("counter.carchargeampere") | float }}

I am sure i need exact your (armedad) solution… but how do i integrate this in my automation?

I think this might be the solution for newbies:
Define the Automation with a fixed value.
Switch to YAML
Chage the Content to something like this:

metadata: {}
data:
  value: |
    {{ states("counter.carchargeampere") | int }}
target:
  entity_id: number.car_charger_set_charge_current
action: number.set_value

Comment: I insert something complete different more close to the Hint of Armedad. But when i retrieve the content for this comment here i found this new content.