Smart Plug not responding and always shows online

Tags: #<Tag:0x00007f616d90d028>

Hello,

I am trying to get my Openhab running on my PC (Linux Mint). I got presence detection working and I want to control my power using these rules, so I got myself a smart plug (E7WIN / Model Number: EW20 S20).

It seems like a plug should be one of the simplest things to set up, but I spent hours trying and I still can’t get anywhere so it would be great if anyone can help me set this up :slight_smile:

Here’s some of my setup:

Things:
network:pingdevice:192_168_0_199 [ hostname="192.168.0.199", retry=2, timeout=6000, refreshInterval=10000 ]

Items:
Switch SmartPlug "Elektriciteit 1" { channel="network:pingdevice:192_168_0_199:online" }

Rules:
rule "power on" when Item SmartPlug changed from OFF to ON then logInfo(plug, SmartPlug.state + " to ON") SmartPlug.sendCommand(ON) end

I found some examples where people use :switch or :power instead of :online, how do I know which to use? PaperUI comes with :online so that’s what I’m using but on PaperUI, the plug is always shown ON, even if it’s not (maybe because it’s pingable?) Response time and Last seen seem to work correctly though.

I’m also not sure what to look for in the logs, but it seems to be fine with text like this:

[DEBUG] [org.eclipse.jetty.server.HttpChannel] - HttpChannelOverHttp@217b922f{r=42,c=false,a=COMPLETING,uri=//localhost:8080/rest/items/SmartPlug} action COMPLETE Item 'SmartPlug' received command ON SmartPlug changed from OFF to ON

The network binding will only tell you us the device is on the network or not. You need to use a binding that is able to talk to this specific switch. Every manufacturer creates their own interface (API).

Assuming that it is a Sonoff S20 smart plug you can follow these instructions to flash the Tasmota firmware on it and control it through the MQTT binding. I don’t think there is a Sonoff binding that will make this work with OH through the vendor’s API.

I agree on tasmota firmware, latest version has even more options.

I wonder if packet capture could be used to get original sonoff credentials then place that into the things file???

It works with Jinvoo devices when integrating with Alexa.

To what end? You still need a binding that knows how to talk to the servers. The Things just provide the parameters needed by the binding. Someone needs to write code that knows how to talk to the API, assuming it is a public API and not closed.

Just because some company makes something that works with Alexa doesn’t mean it has a public API that OH can use without a significant reverse engineering effort, assuming the communication isn’t encrypted.

Thanks, but I don’t think it’s a Sonoff. All I could find was brand E7WIN / Model Number: EW20 S20 and on the plug itself it only says ‘model SU02’.

Also, is there no other simple way to get this to work? All I need is to correctly send ON or OFF to the plug. Even if I would have the tools to follow those instructions, it goes over my head to be honest. I don’t have jumper cables or a USB connection to the plug.

Well, put my foot in my mouth so to speak. Didn’t think about that as I was typing and I type like snail’s run marathons.:smile: Yes, I know what that says about my thinking.:roll_eyes:

Thanks

No. Every device maker creates their own way to control their devices. That is why OH was created and why there are over 330 bindings.

And we don’t know how to do that.There is literally an infinite amount of ways that the makers of this device could define how to send this ON or OFF command. Is there authentication? How is that implemented? Is there encryption? How do I get the key? What encryption algorithm? What do the messages look like? What port do I send the messages to? Can I communicate directly with the device or do I have to talk to the maker’s central servers?

Because it is a wifi socket and

there may be a little (very little) chance the Orvibo binding which supports wifi S20 devices could work for you:

Thanks, The Openhab documentation is not that great and I simply assumed smart plugs are just supposed to work.

I will give Orvibo a try when I’m home again.

A lot of them do work, but you need to find out before you buy any :rofl:
Good luck.

1 Like

So I tried Orvibo and it doesn’t seem to work.