HI,
After carefully setting up all kinds of sensors reading real devices, im finally getting to creating several arithmetic ‘visual’ sensors, based upon those real devices.
Still im struggling a bit, and most of all, believe there should be a better, more reliable, less hard coded way of doing so. I was looking for a way to add all sensors with the ‘actueel’ in it, but couldn’t find a working solution in the templates. Hence, i coded calculated_actual_usage_switches
like this for now, and its working beautifully , that is not the issue.
Please heave a look for me how to make this better. and easier to add new or changed sensors in the future. (have found ou the hard way that hard coding these sensors is prone to problems when setup changes…
below is looking simpler than it really is, since all sensors are based on mqtt sensors themselves, and feeding the complete hub’s data into the Homeassistant. Nevertheless, it must be possible to optimize the code
##########################################################################################
# Berekende waardes van verbruik
##########################################################################################
calculated_actual_usage_switches:
friendly_name: 'Actueel gebruik switches'
unit_of_measurement: 'Watt'
value_template: '{{ ((states.sensor.audio_auditorium_actueel.state |int)
+ (states.sensor.audio_gym_actueel.state |int)
+ (states.sensor.boiler_bijkeuken_actueel.state |int)
+ (states.sensor.cv_garage_actueel.state |int)
+ (states.sensor.cv_stookhok_actueel.state |int)
+ (states.sensor.cv_zolder_actueel.state |int)
+ (states.sensor.dorm_actueel.state |int)
+ (states.sensor.espresso_keuken_actueel.state |int)
+ (states.sensor.freezer_bijkeuken_actueel.state |int)
+ (states.sensor.inductieplaat_actueel.state |int)
+ (states.sensor.quooker_replace_actueel.state |int)
+ (states.sensor.tester_actueel.state |int)
+ (states.sensor.vaatwasser_keuken_actueel.state |int)
+ (states.sensor.wasdroger_bijkeuken_actueel.state |int)
+ (states.sensor.wasmachine_bijkeuken_actueel.state |int)
+ (states.sensor.zonneboiler_zolder_actueel.state |int)) }}'
calculated_nett_usage:
friendly_name: 'Netto verbruik'
unit_of_measurement: 'Watt'
value_template: '{{ ((states.sensor.stroom_actueel_verbruik.state |int)
- (states.sensor.solaredge_production.state |int)) }}'
calculated_zp_minus_usage:
friendly_name: 'Zp solar - actueel'
unit_of_measurement: 'Watt'
value_template: '{{ ((states.sensor.zp_solar.state |int)
- (states.sensor.stroom_actueel_verbruik.state |int)) }}'
calculated_usage_minus_zp:
friendly_name: 'Actueel - zp solar'
unit_of_measurement: 'Watt'
value_template: '{{ ((states.sensor.stroom_actueel_verbruik.state |int)
- (states.sensor.zp_solar.state |int)) }}'
calculated_usage_minus_switches:
friendly_name: 'Ongemeten verbruik'
unit_of_measurement: 'Watt'
value_template: '{{ ((states.sensor.stroom_actueel_verbruik.state |int)
- (states.sensor.calculated_actual_usage_switches.state |int)) }}'
calculated_verbruik_minus_switches:
friendly_name: 'Ongemeten verbruik v2'
unit_of_measurement: 'Watt'
value_template: '{{ ((states.sensor.calculated_nett_usage.state |int)
- (states.sensor.calculated_actual_usage_switches.state |int)) }}'