ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware

That is the item as defined in your items file, in there you have given it the OH-item-name “Switch46”. In the rule you would need the name as setup on the sonoff-device (i.e. “sonoff-AEI”).
Note that according the above mentioned docs the otaurl should read “http://sonoff.maddox.co.uk/tasmota/sonoff.bin” (without “ino”)

When defining the item as a contact instead of a switch it will be read-only.

Yes but you will have you use a map transform from CLOSED to OFF and OPEN to ON and vice versa

Please bear with me.
I still don’t quite understand. I thought sonoff-AEI is the subject/topic for the mqtt broadcast on my sonoff? Do you mean to change the “Switch46” to the host name in the sonoff?

What should i change in the home.items file then?

How do I make amendments for the map transform?

Do I need to define a name for the “broker” in any of the files? mqtt.cfg or something? is that the broker_ clientid?
saw this error in my log:
[WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘home.sitemap’ has errors, therefore ignoring it: [8,21]: mismatched input ‘-’ expecting ‘}’
[9,19]: mismatched input ‘-’ expecting ‘}’ - but its not repeating itself anymore.

You should use the subject/Topic of the mqtt (in your case “sonoff-AEI”) in the file home.rules as the sonoff_device_ID!
Regarding this Point no change in the .items file!

No Change in the mqtt.cfg, BUT you should use the name given to your mqtt broker in the .items file (you used “broker” and “ohbroker”) and in the .rules file (you used “mybroker”)

Look into your .sitemap, the error is in line 8 character 21 and line 9 character 19.

Are you missing a ‘]’ right before the final double quotation mark?

Thanks all. I will get to making the changes as soon as i return from overseas.
update:
Have made the changes
Still not getting any response when I hit on query fw or the other buttons. karaf logs shows that it received the command.

this is my updated home.rules
val sonoff_device_ids = newArrayList(“sonoff46”)

rule “Update Sonoff Status”
when
Time cron “0 0 0 20 * * *” // Update once a day
then
for (String device_id : sonoff_device_ids) {
logInfo(“home.rules”, "Updating FW Item for Device: " + device_id )
publish(“mosB”, “cmnd/” + device_id + “/STATUS”, “2”)
}
end
rule “Sonoff Maintenance”
when
Item Sonoff_Action received command
then
logInfo(“home.rules”, "Sonoff Maintenance on all devices: " + receivedCommand)
for (String device_id : sonoff_device_ids) {
switch (receivedCommand) {
case “restart” :
publish(“mosB”, “cmnd/” + device_id + “/restart”, “1”)
case “queryFW” :
publish(“mosB”, “cmnd/” + device_id + "/status, “2”)
case “upgrade” : {
publish(“mosB”, “cmnd/” + device_id + “/otaurl”, “http://sonoff.maddox.co.uk/tasmota/sonoff.bin”)
publish(“mosB”, “cmnd/” + device_id + “/upgrade”, “1”)
}
}
}
Sonoff_Action.postUpdate(NULL)
end

Latest log error:

2018-10-10 02:57:06.141 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘home.rules’ has errors, therefore ignoring it: [22,66]: mismatched input ‘2’ expecting ‘)’
[24,71]: mismatched input ‘:’ expecting ‘}’
[26,13]: mismatched input ‘}’ expecting ‘end’

Hello my dear,

Please I have two questions:

  • Is Sonoff reliable?
  • Can Sonoff work in alternative with normal light switch, so if the automation system is down the light can be operated from the normal switch (as same as fibaor switch)?

IMHO a Sonoff flashed with TASMOTA is reliable.
The answer on the second question depends!
When the WiFi connection is lost, the sonoff can be switched by the hardware button on the sonoff.

I mean, in Fibaro I connected the relay inside the light switch box and connect the switch.

Then when I turned off the automation system I still can turn on the light using the normal light switch.

Can I do that with Sonoff, not using sonoff button, but the normal switch?

For such a use-case I would suggest a Shelly.

2 Likes

This is first time I hear about SheIly.

I heard that Sonoff is not UL listed and may cause burn :frowning: is it right and What about Shelly ?

Yes,
You wire the normal switch to GPIO14 (The spare one) and configure the sonoff for the relay to toggle the switch

Not anymore, but if your WiFi reception is poor the sonoff may end its life prematurely, The sonoff will use a lot (relatively) of power to reconnect to the wifi or try to keep the connection alive and (apparently) it reduces the life of the sonoff.
Now remember that a LOT of people have experience with sonoffs for a LONG time. They are cheap and easily replaced.
The shelly, however attractive is new and we don’t have reliability data yet.

1 Like

Good to know. Had not heard about this kind of issue. Will file this one away.

@a.tibi - As Vincent says, Shelly is a relatively new player. A recent video from (The Hook Up) Rob mentioned that they are filing for UL listing. A couple of pros for the Shelly is that it’s designed to be used as a hybrid (physical & IoT) switch with external connectors already provided, can use mains power directly, it’s quite small, and also exposes the programming pins to make firmware flashing very easy. I have just received a shipment of these and will be installing them in the following days/weeks (as time permits).

Cheers

Mike

1 Like

That was the reasoning for suggesting Shelly (although it’s new on the floor). The Workaround for a Sonoff is to use the build in button or connect a toggle button to GPIO!4 (as decribed by @vzorglub). Both Solutions are NOT working with an actually used Switch, which is the case for a Shelly.

Jürgen - Do you mean that in either case (Sonoff or Shelly), the wall switch is not controlling the light directly? Yes, that’s good to clarify.

The wall switch is used as an external input to the device. The firmware on the device determines how the switch responds to that input. The device is powered by mains (AC) power and also triggers the mains power through the relay to toggle the light. The device sends a “notification” to the home automation hub to inform it of the state change. This means that the light functions even if the hub is unavailable. If the hub is online, it receives the notification to remain in sync with the actual state of the light. When the hub comes back online, you can query the state of the relay in the device. Of course, you can also use automation via the hub to control the relay.

In the case of using a Sonoff, the wall switch uses LOW DC voltage as the signal on GPIO14. GPIO14 is a pin on the Sonoff PCB which one must wire so it can be used externally (i.e., outside of the Sonoff case).

In the case of the Shelly, the wall switch is wired to mains (AC) voltage. The switch is connected to the Shelly SW input. No modification to the Shelly circuitry is required.

Mike

2 Likes

I meant to say it differntly (more in terms of only the shelly is able ro use the existing high voltage cables). However your explanation tells it in more depth and correct! Thanks.

Yes actually I saw few videos about Shelly, like this one (https://www.youtube.com/watch?v=J20hxfUTP9I), I think Shelly is more convincing.

I even saw this video which let me get rid of thinking about Sonoff (https://www.youtube.com/watch?v=SLK84ZJ291k)

I assumed Shelly is same as Fibaro

Why? This guy is overloading the sonoff at 200%, of course this is going to happen!!
Even at 130% overload the sonoff was stable at 80c. Which is HOT but still safe(ish)

When using ANY kind of electrical appliance, and I count the sonoff as an appliance, one must always make sure that the current for intended use doesn’t exceed the appliance rating. You can always put an in-line fuse for extra safety.

The sonoffs are safe if used within power ratings. You should have you circuit protected for overload. It’s not the sonoff’s job to do that.

The Shelly will also burn eventually when grossly overloaded. Anything will…

3 Likes

Vincent, I vehemently agree with you. I actually think this is a great testimonial FOR the Sonoff. Even when exceeding the rated power (e.g., “a 13A kettle”) for a considerable amount of time, it was able to continue functioning. It performed very well under it’s rated parameters. It is up to the user of the device to use it properly. Even at 200% over rating it took a long time to fail.

@a.tibi - your application is for a light… which will most likely draw under 1 Amp.

1 Like