Why does your entity_id not match the name of your sensor? It should be 1 to 1 unless you changed it manually. I’d verify you’re looking at the correct entity.
As for your template, when you convert the value to an int, you already have a number. So your availability template is doing nothing.
Supply the int with a default of none and check it against none. I.e. the end of your template should be int(default=none, base=16) is not none
Thanks @petro. entity_id doesn’t match being as I have manually added that name. Lol I have about 10 versions of the sensor going, all trying different things to resolve the problem. When I finally get there all the other sensor configs can be deleted and brought back inline with the names.
Sadly this hasn’t worked for me. The sensor now shows ‘Unavaible’ regardless of which of the following I try:
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ (value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) is not none) * value_json['gasMtr']['0702']['03']['01']|int(base=16) / value_json['gasMtr']['0702']['03']['02']|int(base=16) }}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ (value_json['gasMtr']['0702']['00']['00']|int(base=16)) | is_number }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ (value_json['gasMtr']['0702']['00']['00']|int(base=16) * value_json['gasMtr']['0702']['03']['01']|int(base=16) / value_json['gasMtr']['0702']['03']['02']|int(base=16) }}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) is not none }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ (value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) is not none) * value_json['gasMtr']['0702']['03']['01']|int(base=16) / value_json['gasMtr']['0702']['03']['02']|int(base=16) }}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) is not none }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ (value_json['gasMtr']['0702']['00']['00'] * value_json['gasMtr']['0702']['03']['01'] / value_json['gasMtr']['0702']['03']['02'])|int(default=none, base=16) is not none}}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ (value_json['gasMtr']['0702']['00']['00'] * value_json['gasMtr']['0702']['03']['01'] / value_json['gasMtr']['0702']['03']['02'])|int(default=none, base=16) is not none}}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|is_number }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ (value_json['gasMtr']['0702']['00']['00'] * value_json['gasMtr']['0702']['03']['01'] / value_json['gasMtr']['0702']['03']['02'])}}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) is not none }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
@petro sorry to bother you again. I made the changes to the template and the sensor now looks like the following:
- platform: mqtt
name: "Home Gas M3 Raw 2"
state_topic: !secret smart_hild_state_topic
unit_of_measurement: m³
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(base=16) * value_json['gasMtr']['0702']['03']['01']|int(base=16) / value_json['gasMtr']['0702']['03']['02']|int(base=16) }}"
availability:
- topic: !secret smart_hild_state_topic
value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(default=none, base=16) is not none }}"
icon: 'mdi:flash'
device_class: gas
state_class: total_increasing
After restart and allowing MQTT to connect and pull data into HA, the sensor show as ‘Unavailable’. Sorry, but any other suggestions what im doing wrong in this config?
Same here. As of yesterday, my Gas import has gone nuts too, all the values suddenly seem 100x what they should be. Normally I use 1.4m³ now its saying im using 128 m³
Same here, also regular energy spike in energy dashboard and sensors.
I am using grottserver (replaces growatt cloud) and have in in the engery output, battery charge and discharge parameters as well as in some other sensors, like grid frequency:
He’s telling you to not post duplicate questions, which it is. Just bump your other post by replying in it. It’s the same as posting a new topic, but without the second topic. It moves your post to the top of the page and it actually gives it higher relevance when searched in the future.