Hello,
I have tried a few different ways and also had a google and cant find anything that helps, usually it’s easy to find someone else with the same problem but no luck.
Bit of background, so I have a load smart plugs which tell me power in watts, I then use the integration platform to turn that into kwh.
- platform: integration
source: sensor.living_room_devices
name: energy_living_room_devices_kwh
unit_prefix: k
round: 2
I then do hourly, weekly, monthly, yearly using the utility_meter integration
#Utility Per Month
utility_meter:
energy_living_room_devices_month_kwh:
source: sensor.energy_living_room_devices_kwh
cycle: montly
I then take the monthly sensor and created another template sensor to multiply by 0.15p to give me my £ per month cost.
#Living Room Power Usage
- platform: template
sensors:
energy_living_room_devices_month_cost:
value_template: '{{ states.sensor.energy_living_room_devices_month_kwh.state | multiply(0.15) | round(2)}}'
unit_of_measurement: £
friendly_name: 'Living Room Devices Month Cost'
This all works fine but I do wonder if there is a cleaner way of doing it.
But my main question is can I instead of multiply(0.15) can I multiply(another sensor) because I have changed to a different electricity tariff with 30min changes in the price.
I tried the below but with no luck.
- platform: template
sensors:
energy_living_room_devices_new_month_cost:
value_template: '{{ states.sensor.energy_living_room_devices_month_kwh.state | multiply(states.sensor.octopus_current_price.state) | round(2)}}'
unit_of_measurement: £
friendly_name: 'Living Room Devices New Month Cost'
I would need to /100 afterwards as the price comes in as 12 for 12p instead of 0.12.
Any suggestions would be much appreciated.
Cheers