Hassio_g
(Hassio G.)
December 1, 2020, 3:45pm
1
Hi all!
I’m new here and I have a question about converting kW to Watt. I’m pretty inexperienced with Home Assistant and programming things.
I have a smart meter at home and would like to see current usage. I know which entity I need for this. However, the value is shown in kW. I would like to have this expressed in Watts.
Below I have attached a screenshot. How do I adjust it to show the value in Watts?
Thanks in advance!
Regards
1 Like
tom_l
December 1, 2020, 4:07pm
2
You create a template sensor that multiplies your kW sensor by 1000.
sensor:
- platform: template
sensors:
dsmr_in_watts:
friendly_name: "Current Power Usage"
unit_of_measurement: "W"
value_template: "{{ states('sensor.your_dsmr_sensor')|float * 1000 }}"
I couldn’t be bothered writing out your full sensor name as so you will have to fix that in the template.
3 Likes
Hassio_g
(Hassio G.)
December 1, 2020, 4:17pm
3
Hi Tom! Thanks for your quick response!
I’ve tried to place it in the code editor but it does not work. I expect it is not working because I make an error. Where do I need to place the platform template? The full sensor name is: sensor.dsmr_reading_electricity_currently_delivered
tom_l
December 1, 2020, 5:19pm
4
value_template: "{{ states('sensor.dsmr_reading_electricity_currently_delivered')|float * 1000 }}"
Hassio_g
(Hassio G.)
December 1, 2020, 6:16pm
5
Do I need to place that piece of code in the editor like this?
Sorry for my possibly stupid questions. I am just a real newbie
tom_l
December 1, 2020, 6:34pm
6
Nope. That’s not where you put it.
Put it in your configuration.yaml file. You should see a line that says sensor:
Put it all under it like this:
sensor:
- platform: template
sensors:
dsmr_in_watts:
friendly_name: "Current Power Usage"
unit_of_measurement: "W"
value_template: "{{ states('sensor.dsmr_reading_electricity_currently_delivered')|float * 1000 }}"
Unless your sensor line looks like this (which I think it does by default):
sensor: !include sensors.yaml
Then you actually have to put the template sensor in your sensors.yaml file - without the first line (sensors:) like this:
- platform: template
sensors:
dsmr_in_watts:
friendly_name: "Current Power Usage"
unit_of_measurement: "W"
value_template: "{{ states('sensor.dsmr_reading_electricity_currently_delivered')|float * 1000 }}"
After saving the sensors.yaml file restarting home assistant this will create a sensor called sensor.dsmr_in_watts
that you can use in your gauge card.
1 Like
Shaad
(David)
December 1, 2020, 7:12pm
7
You don’t need anymore to restart Home Assistant to update Templates by the way, you just have to restart Template category and that’s so sweet !
tom_l
December 1, 2020, 8:38pm
8
I’ve had bad experiences reloading only parts of HA. I tend not to do it unless I’m in a real hurry (my server restarts in under a minute).
Con
(Con van Doornik)
December 11, 2022, 6:19pm
9
Thanx, perfect solution. I need that to.
Thanks a lot. Was looking for this.
bronco
(Rene)
July 7, 2023, 4:06pm
11
Since a few releases HA has changed the Consumption from W to KW.
Unless you are a high consumer you will see 0 KW used or 1.
I knwo that you can now change it by pressing the entity and then the wheel.
Change KW to W and the precision. Otherewise I only 0 W used.
Pretty anoying because you have to do this everytime you reboot. Yes can use a template to achieve it but it lacks sometimes by a min so not accurate. Also it does not give the Graph.
@tom_l Any ways to make it persistent between reboots? or HA can simply revert it back so how it was?
tom_l
July 7, 2023, 6:02pm
12
I’m not sure what you are talking about. Regarding the unit change. Which integration do you use to create these sensors?
Template sensors update as soon as their source sensors update. And to be used in graphs all you have to do is add a unit_of_measurement.
1 Like
bronco
(Rene)
July 7, 2023, 8:11pm
13
Integration is DSMR Slimme Meter.
The sensor is called sensor.electricity_meter_power_consumption
Are you saying I should use not this one but the other one called DSMR Reader?
I am using the integration and have the same Kw / W issue. (So after reboot my read out says Kw again instead of W. And after every reboot i have to put it back).
1 Like
tom_l
July 8, 2023, 1:24am
15
There is an issue open for this:
opened 09:44AM - 12 Jun 23 UTC
integration: dsmr
### The problem
Hi,
When I restart Home Assistant the 'DSMR Slimme Meter' wi… ll reset the settings of 'meeteenheid' (measuring unit).
I have setup the 'meeteenheid' to W, but after a reboot its kW again.
I can only change it to W again if I first change 'Precisie weergeven' (Show precision) to 0,0 (instead of 0).
Then I can change 'meeteenheid' to W from kW, and than the setting will it be saved correctly.
And finally I change 'Precisie weergeven' (Show precision) to 0 (instead if 0,0).
When i restart/reboot HA again I need to follow the procedure again.
<img width="505" alt="Schermafbeelding 2023-06-12 om 11 32 48" src="https://github.com/home-assistant/core/assets/123647501/ab366ec6-1a57-470a-8165-31419b0f9541">
<img width="506" alt="Schermafbeelding 2023-06-12 om 11 34 26" src="https://github.com/home-assistant/core/assets/123647501/b67cf19c-e968-48fa-b2cf-9b3793491e2a">
<img width="599" alt="Schermafbeelding 2023-06-12 om 11 34 54" src="https://github.com/home-assistant/core/assets/123647501/0aea88be-2ea3-424b-891e-7ab820c8d391">
### What version of Home Assistant Core has the issue?
core-2023.6.1
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant OS
### Integration causing the issue
DSMR Slimme Meter
### Link to integration documentation on our website
https://www.home-assistant.io/integrations/dsmr/
### Diagnostics information
_No response_
### Example YAML snippet
_No response_
### Anything in the logs that might be useful for us?
_No response_
### Additional information
-
Do not add “me too” comments. Just the first post to indicate you have the same issue.
1 Like
I tried to copy your suggestions and put this in the configuration.yaml:
Adding two values worked, but multiplying didn’t.
template:
sensor:
name: “total_grid-eskom”
unit_of_measurement: “A”
device_class: power
state: >
{{ [ states(‘sensor.meter_grid_main_strom_der_phase_a’),
states(‘sensor.meter_grid_battery_strom_der_phase_a’) ]
| map(‘float’,default=0) | sum }}
availability: >
{{ not ‘unavailable’ in
[ states(‘sensor.meter_grid_main_strom_der_phase_a’),
states(‘sensor.meter_grid_battery_strom_der_phase_a’) ] }}
sensor:
platform: template
sensors:
meter_grid-main-w:
friendly_name: “Current Power Usage”
unit_of_measurement: “W”
value_template: “{{ states(‘sensor.meter_grid_main_phase_a_leistung’)|float * 1000 }}”
I am novice but tempted by the possibilities of Home Assistant. Where is my error?
tom_l
December 12, 2023, 9:25am
19
I cant tell because you have not formatted your post correctly .
template:
- sensor:
- name: "total_grid-eskom"
unit_of_measurement: "A"
device_class: power
state: >
{{ [ states('sensor.meter_grid_main_strom_der_phase_a'),
states('sensor.meter_grid_battery_strom_der_phase_a') ]
| map('float',default=0) | sum }}
availability: >
{{ not 'unavailable' in
[ states('sensor.meter_grid_main_strom_der_phase_a'),
states('sensor.meter_grid_battery_strom_der_phase_a') ] }}
sensor:
- platform: template
sensors:
meter_grid-main-w:
friendly_name: "Current Power Usage"
unit_of_measurement: "W"
value_template: "{{ states('sensor.meter_grid_main_phase_a_leistung')|float * 1000 }}"