spirou
(Axel Tischer)
July 14, 2021, 5:43am
#1
Platform information:
RASPI 4
Rasberian
Java Runtime Environment: 11
openHAB version: 3
Issue of the topic: Sencond channel of a tasmota switch show NULL
I defined a thing with two channels using mqtt bindings. The first channel provides the correct value, the second shows always NULL.
What did I wrong ?
UID: mqtt:topic:35b9925914
label: GS-55 Total
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:minion_mqtt
channels:
id: gs_55_sensor_total
channelTypeUID: mqtt:number
label: gs_55_sensor_total
description: ââ
configuration:
commandTopic: ââcmnd/gosound_switches/gosound-55/STATUS 8ââ
formatBeforePublish: â%.4fâ
stateTopic: stat/gosound_switches/gosound-55/STATUS8
transformationPattern: JSONPATH:$.StatusSNS.ENERGY.Total
id: gs_55_sensor_today
channelTypeUID: mqtt:number
label: gs_55_sensor_today
description: ââ
configuration:
commandTopic: ââcmnd/gosound_switches/gosound-55/STATUS 8ââ
stateTopic: stat/gosound_switches/gosound-55/STATUS8
transformationPattern: JSONPATH:$.StatusSNS.ENERGY.Total
opus
(JĂŒrgen Baginski)
July 14, 2021, 6:04am
#2
Without having such a device we would at least need an example of the full Status8
message you are receiving.
spirou
(Axel Tischer)
July 14, 2021, 6:17am
#3
{âStatusSNSâ:{âTimeâ:â2021-07-14T08:14:20â,âENERGYâ:{âTotalStartTimeâ:â2021-07-03T14:29:02â,âTotalâ:0.659,âYesterdayâ:0.054,âTodayâ:0.001,âPowerâ:4,âApparentPowerâ:7,âReactivePowerâ:6,âFactorâ:0.59,âVoltageâ:220,âCurrentâ:0.034}}}
Did you by chance change the type manually in the YAML? This wonât work, and you have to delete and recreate the Channel.
This shouldnât be the issue but both your Channels are extracting Total
1 Like
spirou
(Axel Tischer)
July 14, 2021, 6:58am
#5
No, I didnât change the YAML
Yes, for testing purposes I configured exact the same Pattern, thatâs why I wonder why the first work, the second not. I also tired with Pattern âJSONPATH:$.StatusSNS.ENERGY.Todayâ and got the same result: NULL
Could you reformat your first post and copy/paste your configuration in-between code fences?
Have you linked both Channels to distinct Items?
spirou
(Axel Tischer)
July 14, 2021, 7:30am
#7
Yes both have dedicated items
UID: mqtt:topic:35b9925914
label: GS-55 Total
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:minion_mqtt
channels:
id: gs_55_sensor_total
channelTypeUID: mqtt:number
label: gs_55_sensor_total
description: ââ
configuration:
commandTopic: ââcmnd/gosound_switches/gosound-55/STATUS 8ââ
formatBeforePublish: â%.4fâ
stateTopic: stat/gosound_switches/gosound-55/STATUS8
transformationPattern: JSONPATH:$.StatusSNS.ENERGY.Total
id: gs_55_sensor_today
channelTypeUID: mqtt:number
label: gs_55_sensor_today
description: ââ
configuration:
commandTopic: ââcmnd/gosound_switches/gosound-55/STATUS 8ââ
stateTopic: stat/gosound_switches/gosound-55/STATUS8
transformationPattern: JSONPATH:$.StatusSNS.ENERGY.Total
formatBeforePublish: â%.4fâ
Missing on second channel maybe?
spirou
(Axel Tischer)
July 14, 2021, 9:12am
#9
makes no difference, either the result is handled as string or as float⊠I tried both
rossko57
(Rossko57)
July 14, 2021, 9:26am
#10
formatbeforepublish
has nothing to do with incoming state topics.
Make sure you have not applied profile to your channel-Item links by accident.
Bindings are not always that clever about actioning in-flight edits. After all this editing, when youâve got your best guess set up, try a restart.
spirou
(Axel Tischer)
July 14, 2021, 11:27am
#11
I tried to restart and suddenly I get the value, BUT
when I change something in the second channels it will not be shown neither the value nor the unit, even when I restart
it looks now:
label: GS-55 Total
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:minion_mqtt
channels:
- id: gs_55_sensor_total
channelTypeUID: mqtt:number
label: gs_55_sensor_total
description: ""
configuration:
commandTopic: '"cmnd/gosound_switches/gosound-55/STATUS 8"'
unit: kWh
formatBeforePublish: "%.4f"
stateTopic: stat/gosound_switches/gosound-55/STATUS8
transformationPattern: JSONPATH:$.StatusSNS.ENERGY.Total
- id: gs_55_sensor_today
channelTypeUID: mqtt:number
label: gs_55_sensor_today
description: ""
configuration:
commandTopic: '"cmnd/gosound_switches/gosound-55/STATUS 8"'
unit: kWh
formatBeforePublish: "%.4f"
stateTopic: stat/gosound_switches/gosound-55/STATUS8
transformationPattern: JSONPATH:$.StatusSNS.ENERGY.Today
rossko57
(Rossko57)
July 14, 2021, 11:57am
#12
Good.
What type of Item are you linking to? You may not be aware that MQTT channel parameter unit:kWh
is currently not applied to incoming data (that is being worked on), only to outgoing messages.
So the change you made is suspect. That would look to be your JSONPATH. What does your incoming message payload look like?
spirou
(Axel Tischer)
July 14, 2021, 12:34pm
#13
The incoming message is:
{âStatusSNSâ:{âTimeâ:â2021-07-14T08:14:20â,âENERGYâ:{âTotalStartTimeâ:â2021-07-03T14:29:02â,âTotalâ:0.659,âYesterdayâ:0.054,âTodayâ:0.001,âPowerâ:4,âApparentPowerâ:7,âReactivePowerâ:6,âFactorâ:0.59,âVoltageâ:220,âCurrentâ:0.034}}}
rossko57
(Rossko57)
July 14, 2021, 12:56pm
#14
Looks fine to me. You know this works in general now, and itâs either a mistake in config or Item linking, or your edits not yet taken into account.
spirou
(Axel Tischer)
July 14, 2021, 3:18pm
#15
spirou:
gs_55_sensor_total
Is possible to export items and channels as json/yaml objetcs, so I can compare them?
or copy an item into an other ?
rossko57
(Rossko57)
July 14, 2021, 4:10pm
#16
See the tool API explorer for JSON representation.
spirou
(Axel Tischer)
July 15, 2021, 10:24am
#17
Found the reason:
JSONPATH:$.StatusSNS.ENERGY.Today
must be trigger manually
JSONPATH:$.ENERGY.Today
is triggered periodically by the device