I am working on taking a solar forcast from Home Assistant and using it to calculate the AC battery charge level. So far so good, I have the forecast run a calculation to output the msg:payload (number between 0 and 100), but struggling to send this value back to the HA entity number.lux_ac_battery_charge_level.
I am using the action node the debug node shows the value I want but I get the error HomeAssistantError: expected float for dictionary value @ data[‘value’]
Can anyone help, am I using the best node? What am I doing wrong…
I can’t quite read your screenshot, but you appear to be setting the Action node Data field to
{"value": "msg.payload"}
Since ‘msg.payload’ is in quotes, it will just be the string - “msg.payload”, ie not a number.
You are probably trying to use Mustache templates, so
{"value": {{payload}}}
would be more appropriate, however I would encourage you to use JSONata to form the object here, since Mustache templates are prone to issues when used inside objects.
Set the Data field option dropdown to J: (expression) and use
{"value": payload}
Either works for me.
Edit: It took a bit of digging, but the alternate template tags work too, as long as you check that box and use (with JSON {} option)