I want to switch my statusdisplay via MQTT. I need to add a switch which send “open” in the On position and “close” in the Off position. Therefore I created items
rule "Update Switch Proxy Item"
when
Item Sonoff_Basic_01_String received update
then
if(Sonoff_Basic_01_Switch.state == ON) Sonoff_Basic_01_Switch.postUpdate(OFF)
else Sonoff_Basic_01_Switch.postUpdate(ON)
end
What do I need to change that it works with the open and close command and the switch is switched if it recieved it
Its a sonoff switch, it will turn on and off. The two items above can be reduced to one. You can use MAP transformation to change ON to OPEN, OFF to CLOSED, ect…
What are you referring to as statusdisplay? If this is tasmota you can view all status info by setting Status to 0.
2018-11-29 22:32:46.350 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'Sonoff_Basic_01_Switch' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Configuration 'ON:mosquitto:statusdisplay/status/window/schlafzimmer:command:*:OPEN] >[OFF:mosquitto:statusdisplay/status/window/schlafzimmer:command:*:CLOSE' is not a valid outbound configuration: Configuration requires 5 parameters separated by ':'
You should NOT be using the same MQTT topic for state & command
Read on how Sonoff works and search for other examples in the forum
even this config that I give you here is wrong (it creates a “loop”)
what do mean by this? what are you trying to achieve?
everything as expected now…but i still get one warning
2018-11-30 06:25:44.069 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:Sonoff_Basic_01_Switch in ManagedMetadataProviderImpl, because it does not exists.
When do you get this warning? At startup? Or when you try to perform a certain action? (e.g apply tags via REST)
Maybe you have the same Item name Sonoff_Basic_01_Switch created twice (once in PaperUI and once in the items file). OH2 is trying to apply a tag to the Item but it can’t because it’s not Managed (it has been created manually in items files.
How is then a corect syntax to publish “open” with a switch when it turned on in the topic “mosquitto:statusdisplay/status/window/schlafzimmer” and “closed” when it turned off?
the syntax that I gave you above is correct for doing this part (sending)
It’s not correct for the other part (receiving)
If you want to use one Item to do both, you should be publishing to one topic and subscribing to another
When you press the Button (ON), you will send (due to the xform) “open” MQTT payload to the topic, then the Item will receive the same message for it’s subscription (and will translate it from “open” to “ON” due to the map xform)
It’s pointless to receive the subscription since you already have the updated state when you send a Command.
Plus, in this way, the status is not necessarily the correct one since you don’t know if the device reacted and changed its status.
But … again… this is not how Sonoff is supposed to work (you shouldn’t need to transform the payload and you should already have 2 different topics available=one for commands and one for statuses)
Which firmware are you running on the Sonoff? Vanilla or other?