JoelG
(Joel Gerardi)
March 31, 2024, 2:15pm
1
I have an automation that publishes an mqtt message (cmnd/poolcontrol/mem1) with a value to set mem1 on a sonoff 4ch.
i would like to display the value of that message but cant seem to get it.
I have the following in my yaml config
mqtt:
sensor:
- name: "target temperature"
state_topic: "poolcontrol/mem1"
For my sensor card i have
graph: line
type: sensor
entity: sensor.target_temperature
detail: 1
Not working at all. The cmnd/poolcontrol/mem1 85 is setting mem1 in my sonoff to 85 so i know the message is being published.
tom_l
April 1, 2024, 2:29am
2
Does the sensor have a value (look in Developer Tools → States)?
Is this the first mqtt sensor you have made?
Did you reload or restart after creating it?
You need to restart after using an integration for the first time. After that you can use reload.
francisp
(Francis)
April 1, 2024, 5:34am
3
JoelG:
cmnd/poolcontrol/mem1
Seems like a Tasmota command, in that case the state_topic is probably wrong.
1 Like
JoelG
(Joel Gerardi)
April 1, 2024, 2:56pm
4
Clearly this is all pretty new to me… Actually i am relearning quite a bit. I put this project down about 18 months ago and forgot so much.
In any event, i think my problem is i am trying to publish the value of an mqtt message in a sensor but i am missing something in my yaml (i think)
The sensor yaml is
mqtt:
sensor:
- name: "target temperature"
state_topic: "poolcontrol/mem1"
I think i am missing the value here?
francisp
(Francis)
April 1, 2024, 3:03pm
5
install mqtt explorer (https://mqtt-explorer.com/ ) and look what the state topic of poolcontrol is.
JoelG
(Joel Gerardi)
April 1, 2024, 4:29pm
6
I am getting the result of tele/poolcontrol/result which is {“mem1” :“77”}. All i need from this is the 77. As it is the result is coming up as “entity is non numeric”
francisp
(Francis)
April 1, 2024, 4:33pm
7
mqtt:
sensor:
- name: "target temperature"
state_topic: "tele/poolcontrol/result"
value_template: >-
{{ value_json('mem1') }}
1 Like
JoelG
(Joel Gerardi)
April 1, 2024, 5:01pm
8
I am still getting the non numeric message when i try to display this as a gauge and unknown when i try to display it on a graph.
My graph card is:
An my config file in ha is
mqtt:
sensor:
- name: "target temperature"
state_topic: "tele/poolcontrol/RESULT"
value_template: >-
{{ value_json("mem1") }}
The topic was a typo in my earlier post. RESULT is upper case and it is tele, not stat. Either way tele and stat return the same message.
tom_l
April 1, 2024, 8:42pm
9
value_template: >-
{{ value_json.mem1 }}
or:
value_template: >-
{{ value_json["mem1"] }}
The second one has some advantages in specific situations where the key (mem1) is a reserved word. It’s not in this case so either should work.
1 Like
JoelG
(Joel Gerardi)
April 2, 2024, 11:46am
10
Thanks all. I have it working now. There were a combination of a few things going on. All up an running now.
mattlward
(Matt Ward)
April 2, 2024, 12:57pm
11
I do hope you gave MQTT Explorer a shot, that is hands down the best way to watch your broker and clients. I have about 30 devices that speak MQTT on my network and it really does just give you the answer in an odd situation.