Trying to understand how to go about this I want to set up 2 sensors from a mqtt topic… I currently have this in my configuration.yaml
mqtt:
sensor:
name: "Household Electricity Usage"
icon: mdi:transmission-tower
state_topic: "event/metering/summation/minute"
unit_of_measurement: "kWh"
# the Energy Bridge returns "Watt-minutes" every minute in the "value"; convert it to kilowatt-hours
value_template: "{{ value_json.value | float / 60000 }}"
# the "time" in the message is a Unix-like timestamp (in milliseconds) of the start of the last reading
last_reset_value_template: "{{ now().fromtimestamp(value_json.time / 1000).replace(tzinfo=now().tzinfo) }}"
device_class: energy
state_class: total
but there is second value I want to get into HASS … not just ‘event/metering/summation’ but also ‘event/metering/instantaneous_demand’
so i was looking into creating a sensors.yaml file but this is where I’m struggling … no matter what combo of entries I put in this file I get errors
I think something like this should work… I should be able to add a second sensor… but i don’t understand this error
mqtt:
sensor:
- name: "Household Electricity Usage"
icon: mdi:transmission-tower
state_topic: "event/metering/summation/minute"
unit_of_measurement: "kWh"
# the Energy Bridge returns "Watt-minutes" every minute in the "value"; convert it to kilowatt-hours
value_template: "{{ value_json.value | float / 60000 }}"
# the "time" in the message is a Unix-like timestamp (in milliseconds) of the start of the last reading
last_reset_value_template: "{{ now().fromtimestamp(value_json.time / 1000).replace(tzinfo=now().tzinfo) }}"
device_class: energy
state_class: total
- name: "second sensor"
icon: mdi:transmission-tower
state_topic: "event/metering/instantaneous_demand"
unit_of_measurement: "kWh"
# the Energy Bridge returns "Watt-minutes" every minute in the "value"; convert it to kilowatt-hours
value_template: "{{ value_json.value | float / 60000 }}"
# the "time" in the message is a Unix-like timestamp (in milliseconds) of the start of the last reading
last_reset_value_template: "{{ now().fromtimestamp(value_json.time / 1000).replace(tzinfo=now().tzinfo) }}"
device_class: energy
state_class: total
mqtt:
sensor:
- name: "Household Electricity Usage"
icon: mdi:transmission-tower
state_topic: "event/metering/summation/minute"
unit_of_measurement: "kWh"
# the Energy Bridge returns "Watt-minutes" every minute in the "value"; convert it to kilowatt-hours
value_template: "{{ value_json.value | float / 60000 }}"
# the "time" in the message is a Unix-like timestamp (in milliseconds) of the start of the last reading
last_reset_value_template: "{{ now().fromtimestamp(value_json.time / 1000).replace(tzinfo=now().tzinfo) }}"
device_class: energy
state_class: total
- name: "second sensor"
icon: mdi:transmission-tower
state_topic: "event/metering/instantaneous_demand"
unit_of_measurement: "kWh"
# the Energy Bridge returns "Watt-minutes" every minute in the "value"; convert it to kilowatt-hours
value_template: "{{ value_json.value | float / 60000 }}"
# the "time" in the message is a Unix-like timestamp (in milliseconds) of the start of the last reading
last_reset_value_template: "{{ now().fromtimestamp(value_json.time / 1000).replace(tzinfo=now().tzinfo) }}"
device_class: energy
state_class: total
@francisp just want to say thanks for all your pointers… I finally figured it out. Learnt the way to set up a directory with individual sensor configurations and how the hierachy works when defining in the configuration.yaml
More importantly… 2 other things. The plugins aren’t always reliable for configuration you really have to go back to the documentation of the current version to confirm you have it right. Second don’t copy/paste stuff from the www … more than likely it’s for an older version of HASS so doesn’t work quite the same anymore …