Good morning and sorry for my english, i made this custom sensor that bring data from a sensor that gmcan goes positive or negative (it’s a shelly em connected to the main breaker and if the solar energy is higher that the home consuption it goes to negative). In this case, this sensor have to show only the positive numbers, in case of negative, have to show 0, then i can make a meter that count the W to make an accurate “real consumes from the electric company sensor” this is the code
template:
- sensor:
- name: consumi_positivi_da_rete_enel
friendly_name: "Consumi positivi da rete enel"
state_class: measurement
device_class: power
unit_of_measurement: W
state: "{{ 0 if states('sensor.consumo_enel_power')|float(0) < 0 else states('sensor.consumo_enel_power') }}"
availability: "{{ has_value('sensor.consumo_enel_power') }}"
Where i make error? In the log i can’t see error and also in studio code. I really appreciate a solution, thanks
I thought that was only to specify where the sensir ditectory is, because the other sensor file works but maybe i don’t understa d something in the proces
You are not making a sensor: entity; you are making a template: entity. Put all of the code in your original post (without the friendly_name line) directly into configuration.yaml.