Hi to all!
I cannot use a sensor to read my gas counter.
So, I manually take the measure every saturday.
I put it into a custom mqtt sensor:
sensor:
- platform: mqtt
name: "Gas reading"
icon: mdi:stove
state_topic: "utilities/gas/reading"
value_template: "{{ value_json.value }}"
unit_of_measurement: "m3"
payload_available: "true"
payload_not_available: "false"
input_number:
gas_reading:
name: Lettura
min: 0
max: 9999
mode: box
script:
gas_reading_save:
alias: "Salva lettura"
sequence:
service: mqtt.publish
data_template:
topic: utilities/gas/reading
payload_template: >-
{
"value": "{{ states('input_number.gas_reading') | int }}"
}
retain: true
utility_meter:
gas_meter_monthly:
name: Consumo gas mensile
source: sensor.gas_reading
cycle: monthly
gas_meter_yearly:
name: Consumo gas annuale
source: sensor.gas_reading
cycle: yearly
Of course now I would use the new gas dashboard.
How I need to adapth the mqtt sensor? Is it possible?
Thank you very much!
EDIT:
I added the state_class: total_increasing
value, but I cannot see it on dashboard.
Now sensor is:
sensor:
- platform: mqtt
name: "Gas reading"
icon: mdi:stove
state_topic: "utilities/gas/reading"
value_template: "{{ value_json.value }}"
unit_of_measurement: "m3"
payload_available: "true"
payload_not_available: "false"
state_class: total_increasing
device_class: gas
This is the image from developers tools:
Instead this is the image from ShellyEM that I use to feed the energy dashboard - it seems to me very, very similar!
But HASS complaints with me that with gas there are no statistics available…