Hello,
I´m trying to create a simple MQTT-Battery-sensor for the Wallpanel App from
Is there something missing in my code or is it wrong formatted?
Thanks for help!
Philipp
This is my code:
- platform: mqtt
state_topic: "wallpanel/trekstor/sensor/battery"
name: "TrekStor Battery Level"
unit_of_measurement: "%"
device_class: battery
value_template: "{{ value }}"
And this is what I get:
gpbenton
(Graham)
December 21, 2019, 11:39am
2
I think you need to tell the template it is interpereting json
value_template: "{{ value_json.value }}"
That worked, thanks a lot!
Merry X-mas everybody!
Sorry I need help again with this thing. I just want to make a sensor that shows me if the device is ac plugged or not.
I tried it by myself but got no result at all. I guess something important is missing…again.
binary_sensor:
- platform: mqtt
state_topic: "wallpanel/huawei/sensor/battery"
name: "Mediapad AC"
payload_on: '{"acPlugged":true}'
payload_off: '{"acPlugged":false}'
device_class: "plug"
payload_available: "ON"
payload_not_available: "OFF"
Well, I got it by myself. Not the best-practice solution I guess, but it works
1.) I used an ordinary sensor, not a binary_sensor:
- platform: mqtt
state_topic: "wallpanel/huawei/sensor/battery"
name: "Mediapad AC"
value_template: "{{ value_json.acPlugged }}"
2.) I made a sensor template to rename the output
mediapadac:
friendly_name: "Mediapad power"
value_template: >-
{% if is_state('sensor.mediapad_ac', 'True') %}
On
{% else %}
Off
{% endif %}
traviz
(Christoph)
January 1, 2021, 7:04pm
6
Hi, I had the same issue and solved it like below:
put the code into binary_sensors.yaml
- platform: mqtt
state_topic: "wallpanel/tablet/sensor/battery"
name: "Mediapad (plug)"
value_template: "{{ value_json.acPlugged }}"
payload_on: true
payload_off: false
device_class: plug
ofcourse you have to have additional line in configuration.yaml
binary_sensor: !include binary_sensors.yaml