Im trying to display my current solar power (FoxESS - PV Power) on my awtrix device, its showing but its expecting W from the sensor but its receiving KW, is there a template or automation that can convert this or create a new sensor?
you read here
and scroll down a bit until you reach
State based sensor - Changing the unit of measurement of another sensor
This example matches your request next to 99%
but you must multiply by 1000 not 1024 and simply replace your entity names and the unit_of_measurement
- sensor:
- name: "Solar Power Watt"
unit_of_measurement: "W"
state: "{{ states('sensor.foxess_pv_power')|float * 1000 }}"
i think this has done it? i see the new sensor but now my solar isnt producing anything to test, ill check back in the morning
does that short code look correct if the sensor name is âsensor.foxess_pv_powerâ that im trying to convert?
You should read the hint given ⌠a 2nd time âŚ
Instead of using the âfancy nameâ use the entity.name âŚ
in the form sensor.<whatsoever itâs name is>
And ask yourself why you didnât implement the âavailability:â line to ensure that a calculation wonât throw an error in case your original sensor becomes
unknown (unkown * 1000 isnâr a valid calculation, or unavailable (unavailable * 1000) neither.
It helps you to get errormessages pointing to the real error not an error which is a followup to another error.
EDIT: Iâd say sensor.foxess_pb_power looks correct.
yeah i found that problem and found the correct sensor. names and now working great, thanks for your help, as i say im VERY new to this and have zero experience writing any kind of code
you can add some more lines to make more from it.
state_class: measurement
device_class: power
Better said, leave the state_class, establish the template sensor and then go to
dev.tools (left menu in HA)>States
and enter âpowerâ in the filter field.
When you located your template entity press the small i in the circle
Remember what you see.
Then add the line starting with state_class and check the same thing.
If being a measurement lets you view the entity in a graphical chart, a line chart for example, without you get bars of values.
device_class is a differnt story, in short â10.1 Wâ without a device_class is a number, 10.1 with a trailing âWâ which your brain translated being a value of type power. But HA hasnât got your brain, since so if you want to let HA know itâs a power value you must define it.
For the sake to use a Rieman sum helper and create an energy energy entity from it.
And again ⌠if you would do so, the energy entity would fails in case this power entity fails if only your foxess entity failed since the last one depends upon itâs feeding entities. (availability ⌠is important)