I’m trying to add a Tasmota Sonoff T1 UK 2CH switch via PaperUI.
I have it set up so that I can see that it is being received by the broker, however I think I need to define some sort of transformation for ON=1 and OFF=0, but am confused by the JSON transformation script option in the PaperUI.
I get the following error:
[WARN ] [hab.binding.mqtt.generic.ChannelState] - Command '{"POWER1":"ON"}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"POWER1":"ON"}
20:05:12.402 [WARN ] [e.core.thing.binding.BaseThingHandler] - Handler GenericMQTTThingHandler tried updating the thing status although the handler was already disposed.
EDIT: I added the following in the transformation options:
{"POWER1":"ON"}
and:
{"POWER1":"OFF"}
which seems to have done the trick, however I still get the warning:
20:05:12.402 [WARN ] [e.core.thing.binding.BaseThingHandler] - Handler GenericMQTTThingHandler tried updating the thing status although the handler was already disposed.
I think I need to ditch the PaperUI and perhaps add my MQTT Sonoff things in the things file.
I have managed to read the switch over MQTT, and with a rule I can switch a Hue light on and off, but what I need to figure out is how to update the switch state when some other input changes the state of the light (Alexa for instance).
What I’m trying to achieve, is the LED on the switch should turn off when I turn the light on and on when I turn the light off. This is fine if I am using the switch, but if I use Alexa to turn the light on and off, the state of the switch doesn’t toggle to reflect the change.
This is fairly easy (though it’s all relative!) - when a Tasmota device receives a command from anything it will publish a response on the RESULT topic. At the very least, that RESULT message will include the POWER state.
OpenHAB can subscribe to these RESULT topics using the stateTopic property of a thing, which means it is ‘constantly listening’ for them. Once received, you can then update your item with the required information.
If you show a screenshot of your Tasmota MQTT setup page we could probably guide you through setting up the things, items and sitemap required.
I’m currently on the phone though, so maybe see if the following link helps? It’s for an RGB LED strip, but the controller has Tasmota on it…
The issue with the link you posted is that it is a text based configuration for mosquitto.
I’m using the embedded broker, which is already configured via paperUI.
In the past I have used mosquitto as my broker, and a text based configuration, with these same switches…however, it was a few years ago, and I’ve forgotten how to set this up.
I have Mosquitto installed and running, I have defined my Things file as described in the RGB strip controller linked a few posts above, but am having an issue with the JSON transformation:
13:55:54.755 [WARN ] [tt.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"POWER1":"ON"}'
This is probably a result of using the RESULT topic in stateTopic. Anytime anything changes in the device the RESULT topic will be fired. As both channels subscribe to that topic they will both try to extract their particular JSONPATH. One will of course be wrong.
What happens if you use stat/Porch/POWER1 in the stateTopic for the first channel, and stat/Porch/POWER2 in the second channel?
I’ve also just noticed: your commandTopic should probably be something like cmnd/Porch/POWER1 for the first channel, and similarly cmnd/Porch/POWER2 for the second.
And lastly, the second channel change
Type switch:switch "Power2"
to
Type switch:switch2 "Power2"
The name after the colon is the unique identifier for that channel, so it must be unique!