JSON Transform MQTT Help

Sorry for the long post in advance.

Everything is working properly, I am having some trouble getting rid of these warning from my log. I am not sure if I need to use a rule or how to create a JS or use the proper Transform.

I am contolling a Tasmota ESP8266 WiFi Light (Dimmer) and Fan Controller.

These are the warnings…

[t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.Dimmer' in '{"POWER1":"ON"}'
[t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER2' in '{"POWER1":"ON"}'
[t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.Dimmer' in '{"POWER2":"ON"}'

This is my MQTT thing.

Thing topic EndBedroomLightsFan "End Bedroom Lights Fan" {
		Channels:
			Type switch : fanpower 		"Fan Power Switch"		[ stateTopic= "EndBedroomLightsFan/stat/POWER1", commandTopic="EndBedroomLightsFan/cmnd/POWER1", on="ON", off="OFF"] 
			Type string : fanspeed 		"Fan Speed"				[ stateTopic= "EndBedroomLightsFan/stat/speed", commandTopic="EndBedroomLightsFan/cmnd/tuyasend4", turtle="3,0", low="3,1", medium="3,2", high="3,3"]
			Type switch : lightspower 	"Lights Power Switch"	[ stateTopic= "EndBedroomLightsFan/stat/RESULT", transformationPattern="JSONPATH:$.POWER2", commandTopic="EndBedroomLightsFan/cmnd/POWER2", ON="ON", OFF="OFF"]
			Type dimmer : lightspercent	"Lights Percent"		[ stateTopic= "EndBedroomLightsFan/stat/RESULT", transformationPattern="JSONPATH:$.Dimmer", commandTopic="EndBedroomLightsFan/cmnd/Dimmer"]
			
	}

Whenever the MQTT comes in, the RESULT topic is not consistent and always changes according to whatever is controlled on the Light/Fan switch.

  • When Fan Power Switch is turned on/off it send the MQTT message {“POWER1”:“OFF”}
  • When Light Power Switch is turned on/off it send the MQTT message {“POWER2”:“OFF”}
  • Whenever Dimmer is adjusted it send the MQTT message {“POWER2”:“ON”,“Dimmer”:72}

This is what creates the error according to my transformationPattern you can see there is not a valid path when looking at my Thing.

Any idea how do I go about trying to get rid of these warnings and properly handle this Thing? I am not a very strong Javascript/ JSON person so I am sure this could be easy if you know what you are doing :sweat_smile:

Thanks!

See

You could setoption4 1 in tasmota which will change the MQTT structure and more easily handled by openhab using different stateTopics

Or as @rossko57 suggests filter

Install regex transformations

Thing topic EndBedroomLightsFan "End Bedroom Lights Fan" {
		Channels:
			Type switch : fanpower 		"Fan Power Switch"		[ stateTopic= "EndBedroomLightsFan/stat/POWER1", commandTopic="EndBedroomLightsFan/cmnd/POWER1", on="ON", off="OFF"] 
			Type string : fanspeed 		"Fan Speed"				[ stateTopic= "EndBedroomLightsFan/stat/speed", commandTopic="EndBedroomLightsFan/cmnd/tuyasend4", turtle="3,0", low="3,1", medium="3,2", high="3,3"]
			Type switch : lightspower 	"Lights Power Switch"	[ stateTopic= "EndBedroomLightsFan/stat/RESULT", transformationPattern="REGEX:(.*POWER2.*)∩JSONPATH:$.POWER2", commandTopic="EndBedroomLightsFan/cmnd/POWER2", ON="ON", OFF="OFF"]
			Type dimmer : lightspercent	"Lights Percent"		[ stateTopic= "EndBedroomLightsFan/stat/RESULT", transformationPattern="REGEX:(.*Dimmer.*)∩JSONPATH:$.Dimmer", commandTopic="EndBedroomLightsFan/cmnd/Dimmer"]
			
	}
1 Like

This is exactly what I was looking for, thanks !

What does “∩” mean exactly? I have never seen that one used before.

I didn’t know you could do this. This would have worked too !

It is an intersection symbol