Changing entity value by other entity value

Hello there, I try to improve my PV-Battery-system. Target is to adjust the Power-Input of the battery (Anker solar bank E1600, uptodate firmware and integration). Therefore I have several Shelly and Tapo plugs which tell how much power is actually needed (simple self-made sensor called “AktuellerVerbrauch”).

For testing I could manage by using the Automation UI to change the entity “number.solarbank_e1600_system_einspeisevorgabe” in dependency of the value of AktuellerVerbrauch (Time-triggered (every Minute)) for several power intervals (0-200, 201-300 … 800+). The number.solarbank_e1600_system_einspeisevorgabe changes as I want it - for each interval to the respective x50 (150, 250 … 800).

Sometimes the power consumption is at e.g. 290, which is far away of 250 of the automated input. I think that can be a bit nearer to the actual power consumption. So I think I can calculate a better value for number.solarbank_e1600_system_einspeisevorgabe:
My attempt is:

number.solarbank_e1600_system_einspeisevorgabe = (((( states('AktuellerVerbrauch') * 1,1 / 10 ) |float) |round(0) * 10) |float ) |round(0)

(the number.solarbank_e1600_system_einspeisevorgabe can only be between 150 and 800 and also only devidable by 10 (160,170…). That’s why there is the rounding etc.

But how do I get it into the Automation UI or YAML? Actually I tried to write it into the “Define Variable Box” but after saving the calculation (several syntax tried) is changed to

variables:
  sensor.solarbank_e1600_einspeisevorgabe:
    "[object Object]": null

Hope you can understand my problem and help me out. Thanks in Advance.

I don’t understand at all what the purpose of any of this is, as I have no idea what those german words mixed in mean. But you cannot simply “assign” a new value to an entity.

It is quite ambiguous from your post whether this entity is a number or a sensor. If it is a number, use the number.set_value action. Use the visual editor to construct the action if you don’t know anything about YAML syntax. If it is a sensor you cannot change its value, only make an entirely new substitute sensor whose value is based on the original sensor.

The template you’ve tried to write is a complete WTF? :sweat_smile: Why are you dividing by 10, rounding off decimals, multiplying back the same 10 you took off, rounding of non-existent decimals again, and several conversions to float which will make no difference at all (but not one where it would actually be needed)? Unless I’ve missed something this heavily reduced template should do the exact same thing, except it’ll actually work…

"{{ (states('AktuellerVerbrauch') | float(0) * 1.1) | round(1) }}"

Edit: Nevermind, it won’t work, as ‘AktuellerVerbrauch’ cannot possibly be a valid entity ID. You will need to substitute in the correct entity ID.