MOES zigbee smart plug exposes a String instead of Switch item

hi,
I’ve got this device
Moes MOES_plug control via MQTT | Zigbee2MQTT

Exposes

Switch

The current state of this switch is in the published state under the state property (value is ON or OFF). To control this switch publish a message to topic zigbee2mqtt/FRIENDLY_NAME/set with payload {"state": "ON"}, {"state": "OFF"} or {"state": "TOGGLE"}. To read the current state of this switch publish a message to topic zigbee2mqtt/FRIENDLY_NAME/get with payload {"state": ""}.

It seems it exposes a switch as a string item (as it can receive TOGGLE command, not just ON/OFF)

So I’ve created a String Thing, and a String item, and everything works (tested by sending commands ON OFF TOGGLE to it in karaf).

I’ve cheated my way through sitemap by adding a Switch Item to a sitemap (pointing to a item name that is actually a String). I’m surprised this even worked :slight_smile:
But now a problem I have is, while everything is fine on the sitemap, but MainUI of course cannot switch a string. I am using semantic hierarchy, so my MainUI got populated automatically, and I have a string amongst switches.

First of all, it seems impractical to have a smart plug that does not produce a switch item, just unnecessary complication. But cannot complain much as these plugs are nice and small and go for 10 euros on aliexpress :slight_smile:

Is there any elegant way to solve this, other than creating a proxy switch, and having rules handle the switching of the switch?

Am I overseeing something obvious? I tried changing the item and thing from string to switch but it doesnt work…

EDIT: Also, I added this item to some lights group switch, but it doesn’t get switched off with a group OFF because its not a switch…

EDIT2: could I utilize a follow profile for this dummy switch to follow the state of the string item and vice versa?

Hi perhaps I am misunderstanding you but why can’t you just add a new channel and define it as a on/off switch? then configure the channel with your set commands?

hi,
things

        Thing topic Kitchen "Kitchen Light" @ "Kitchen"
    {
        Channels:
            Type string : state "state" [ stateTopic = "zigbee2mqtt/Kitchen/state", commandTopic = "zigbee2mqtt/Kitchen/set" ]  
            Type string : indicator_mode "indicator_mode" [ stateTopic = "zigbee2mqtt/Kitchen/indicator_mode", commandTopic = "zigbee2mqtt/Kitchen/set" ]    
            Type number : power "power" [ stateTopic = "zigbee2mqtt/Kitchen/power" ]     
            Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/Kitchen/linkquality" ]    

items

String Kitchen           "Kitchen [%s]" <light> (gLivingRoomLights,gCountAllLights)  ["Light", "Lighting"]  {channel="mqtt:topic:mosquitto:Kitchen:state"}
String Kitchen_Indicator "Kitchen Indicator [%d]"    {channel="mqtt:topic:mosquitto:Kitchen:indicator_mode"}
Number Kitchen_Power     "Kitchen Power Usage [%.1f %%]" <battery>  {channel="mqtt:topic:mosquitto:Kitchen:power"}
Number Kitchen_Link      "Kitchen Link [%d]"    {channel="mqtt:topic:mosquitto:Kitchen:linkquality"}

i tried replacing the first channel from string to a switch, and first item from string to a switch, but it doesnt work. I want to define them as switch not a string, but dont know how…

have a look here.

It discusses Defining a channel manually.
but you should be able to add something like this

Type switch : Powerswitch [ stateTopic = "zigbee2mqtt/Kitchen/state", commandTopic = "zigbee2mqtt/Kitchen/set", on="ON", off="OFF"]
1 Like

thanks man, it works.
and then i have pointed my item to the custom channel “/powerswitch”

Switch Kitchen           "Kitchen [%s]" <light> (gLivingRoomLights,gCountAllLights)  ["Light", "Lighting"]  {channel="mqtt:topic:mosquitto:Kitchen:powerswitch"}