so i working on a energy sensor as i going to order Clamp meters so i made 3 values L1 L2 and Total i did this twice for my shop and house
i can do L1 and L2 but when i do the Total sensor adding L1 and L2 it removes my other generatored sensors… i have had it if it will just do 50 + 50 but it wont add it as 100
here is part of it
template:
sensors:
# # House KW/H Used"
grid_energy_house_l1_imported:
friendly_name: "Grid Energy House L1 Imported"
value_template: "{{ states('sensor.back_room_light_1_power')|float(0) }}"
unit_of_measurement: "kwh"
grid_energy_house_l2_imported:
friendly_name: "Grid Energy House L2 Imported"
value_template: "{{ states('sensor.back_room_light_2_power')|float(0) }}"
unit_of_measurement: "kwh"
grid_energy_house_Total_imported:
friendly_name: "Grid Energy House Total Imported"
value_template: "{{ states('sensor.grid_energy_house_l1_imported')| float(0) + states('sensor.grid_energy_house_l2_imported')| float(0)}}"
unit_of_measurement: "kwh"
so the L1 and L2 work the first 2 but if i run the 2nd one it removes the the first two and doesnt generate the math…
what is wrong with my coding as i googled how to add it but its not
@tom_l
ok i think i got it… i didnt install the integral is that when you need to convert power to kWh? and how come you need to install intergration you cant just do the math?
either way i had the energy option its already in kWh so i changed it… i doing this ahead of time as i trying to setup the utlility meter and energy dashboard with my automation… and the 2 L1 L2 are fillers till i get the clamp meter versions that i ordered… so once it comes i can change the back room 1 energy to the new sensor… but i think its all correct… it seems to be working
packages_power_grid:
template:
- sensor:
## House Energy ##
- name: "Grid Energy House L1 Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy')|float(0) }}"
- name: "Grid Energy House L2 Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy')|float(0) }}"
- name: "Grid Energy House Total Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.grid_energy_house_l1_imported') | float(0) + states('sensor.grid_energy_house_l2_imported') | float(0) }}"
availability: "{{ has_value('sensor.grid_energy_house_l1_imported') and has_value('sensor.grid_energy_house_l2_imported') }}"
## Building Energy ##
- name: "Grid Energy Building L1 Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy')|float(0) }}"
- name: "Grid Energy Building L2 Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy')|float(0) }}"
- name: "Grid Energy Building Total Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.grid_energy_building_l1_imported') | float(0) + states('sensor.grid_energy_building_l2_imported') | float(0) }}"
availability: "{{ has_value('sensor.grid_energy_building_l1_imported') and has_value('sensor.grid_energy_building_l2_imported') }}"
## Total Energy Imported House & Building ##
- name: "Grid Energy Total Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.grid_energy_building_total_imported') | float(0) + states('sensor.grid_energy_house_total_imported') | float(0) }}"
availability: "{{ has_value('sensor.grid_energy_building_total_imported') and has_value('sensor.grid_energy_house_total_imported') }}"
and i appreciate the help as i was spinning… and i didnt know the sensors had changed way its entered in… as i was just moving my old sensors around … i guess i should update all my sensors to the new way
It is just a copy of an existing sensor. Why not just use sensor.back_room_light_1_energy in your energy sum?
You could simplify this:
## Building Energy ##
- name: "Grid Energy Building L1 Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy')|float(0) }}"
- name: "Grid Energy Building L2 Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy')|float(0) }}"
- name: "Grid Energy Building Total Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.grid_energy_building_l1_imported') | float(0) + states('sensor.grid_energy_building_l2_imported') | float(0) }}"
availability: "{{ has_value('sensor.grid_energy_building_l1_imported')
To this:
## Building Energy ##
- name: "Grid Energy Building Total Imported"
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
state: "{{ states('sensor.back_room_light_1_energy') | float + states('sensor.back_room_light_2_energy') | float }}"
availability: "{{ has_value('sensor.back_room_light_1_energy') and has_value('sensor.back_room_light_2_energy') }}"
You don’t need to supply a default value for your float filters if using the availability template.
I’m also assuming you got the entity id wrong for building 2.
ah ok always learning
so what i doing is just using sensor.back_room_light_1_energy and sensor.back_room_light_2_energy as a dummy sensor for the time being till i get clamp
so ill have 4 sensors
200 amp L1 200 amp L2 for incoming the the Shop House Panel
200 amp L1 200 amp L2 for incoming to the Shop Panel
then i add the total together so i have Total House Incoming kWh
and total Shop Incoming kWh
then i add the Shop and House so ill have a price of my montly of what House and Shop are at same time
and i ordered the Shelly Pro EM 400 amp so i can measure up to 400 amps per wire
ill double check my entitys
and the L1 and L2 is just the 2 Wires that come into your home into the Panel to power your house if were asking what i ment by L1 when ya qouted
this is for the 220V that comes in the house 120v 200amp L1 120v 200 amp L2 so then i have 220v so i measuring both wires
ah ok ya they just dummy load i wanted to get this all setup so i wasnt trying to fiddle with this when the shellys come in… so i wanted to practice work out the bugs …
and when do you use float and float(0) when is it you use either or benefits.
Use float(n) where n is your default value if the filter can’t convert the state to a number.
However if you use an availability template this is evaluated before the state template. If the availability template result is false then the state template is not evaluated, so you don’t need the defaults for your float filters. Does not hurt to include the defaults, they will just never be used.
oh ok learning something new everyday… i appreciate the help so far… now i need to work on converting to the new way to do the sensors… hopefully doesnt change for a long time lol dont wanna change it again lol