This is a WiFi Smart Switch with the DIY capability that makes it possible to control connected devices via the eWeLink directly from your phone, or ask it to turn on/off devices with Amazon Alexa and Google Assistant. Amazingly, it has a DIY mode that is the firmware can be user-defined. Built-in a web server that exposes the REST API, which allows you to connect the switch with your existing home automation system. Compatible with Vera, Fibaro, HomeSeer, Savant, HomeKit, etc.
SONOFF BASICR3
Moderator: leecollings
SONOFF BASICR3
https://www.itead.cc/sonoff-basicr3-wif ... witch.html
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
It would be nice to have it in Domoticz.
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
I am not sure if it can be implemented the multicast-DNS based zeroconf Sonoff DIY mode handler routine inside a Domoticz Python plugin. But i have created an external DIY->MQTT translator application for testing.
https://github.com/enesbcs/sonoffdiy2mqtt
In the "sonoffdiy2mqtt.json" file the default mode is "mqtt_type": "domoticz" when the
Sonoff Device ID (ten character hexadecimal) has to be added to the "sonoff_device_id" fields and its correspondent, Domoticz Dummy device IDX has to be added in the same line to the "outlet0".
Necessarry Domoticz Hardwares: "MQTT Client Gateway with Lan interface" and "Dummy"
If inside the "sonoffdiy2mqtt.json" settings the "mqtt_type": "shelly" is setted then the sonoffdiy2mqtt script translates incoming mDNS messages to Shelly API compatible MQTT messages and paths, which can be intercepted by the Domoticz hardware "Shelly MQTT". ( https://github.com/enesbcs/Shelly_MQTT ) In this mode IDX is not required, but make sure to enable device self-learning.
https://github.com/enesbcs/sonoffdiy2mqtt
In the "sonoffdiy2mqtt.json" file the default mode is "mqtt_type": "domoticz" when the
Sonoff Device ID (ten character hexadecimal) has to be added to the "sonoff_device_id" fields and its correspondent, Domoticz Dummy device IDX has to be added in the same line to the "outlet0".
Necessarry Domoticz Hardwares: "MQTT Client Gateway with Lan interface" and "Dummy"
If inside the "sonoffdiy2mqtt.json" settings the "mqtt_type": "shelly" is setted then the sonoffdiy2mqtt script translates incoming mDNS messages to Shelly API compatible MQTT messages and paths, which can be intercepted by the Domoticz hardware "Shelly MQTT". ( https://github.com/enesbcs/Shelly_MQTT ) In this mode IDX is not required, but make sure to enable device self-learning.
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
Nice, I'll give it a try next week.
How do you get the sonoff_device_id ?
How do you get the sonoff_device_id ?
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
You have to run it once, does not matter if it is configured or not, but if it finds a DIY plug through local mDNS than it writes it's Device ID's which you can copy-paste into the .json settings file.chatainsim wrote: ↑Thursday 08 August 2019 22:34 Nice, I'll give it a try next week.
How do you get the sonoff_device_id ?
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
Thanks, it's working fine.lwolf wrote: ↑Friday 09 August 2019 7:35You have to run it once, does not matter if it is configured or not, but if it finds a DIY plug through local mDNS than it writes it's Device ID's which you can copy-paste into the .json settings file.chatainsim wrote: ↑Thursday 08 August 2019 22:34 Nice, I'll give it a try next week.
How do you get the sonoff_device_id ?
The only thing is I'm not able to create a systemd script.
It start then stop immediately.
Do you know how to setup a correct systemd init file ?
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
Maybe the init file you have done tried to start before network/mqtt, which will not work.chatainsim wrote: ↑Monday 12 August 2019 9:42Thanks, it's working fine.lwolf wrote: ↑Friday 09 August 2019 7:35You have to run it once, does not matter if it is configured or not, but if it finds a DIY plug through local mDNS than it writes it's Device ID's which you can copy-paste into the .json settings file.chatainsim wrote: ↑Thursday 08 August 2019 22:34 Nice, I'll give it a try next week.
How do you get the sonoff_device_id ?
The only thing is I'm not able to create a systemd script.
It start then stop immediately.
Do you know how to setup a correct systemd init file ?
Did you try the simple /etc/rc.local startup?
https://www.claudiokuenzler.com/blog/78 ... d-rc-local
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
I have some issue with the script.
Sometimes when I turn off the SonOff, it turn on again immediatly.
Same when I turn it on.
For MQTT I've setuped the Publish Topic to out, is it correct ?
Sometimes when I turn off the SonOff, it turn on again immediatly.
Same when I turn it on.
For MQTT I've setuped the Publish Topic to out, is it correct ?
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
The systemd script is started by hand network and mqtt is already started.lwolf wrote: ↑Monday 12 August 2019 17:31Maybe the init file you have done tried to start before network/mqtt, which will not work.chatainsim wrote: ↑Monday 12 August 2019 9:42Thanks, it's working fine.
The only thing is I'm not able to create a systemd script.
It start then stop immediately.
Do you know how to setup a correct systemd init file ?
Did you try the simple /etc/rc.local startup?
https://www.claudiokuenzler.com/blog/78 ... d-rc-local
Code: Select all
pi@raspberrypi:~ $ sudo systemctl status sonoffdiy
● sonoffdiy.service - System Sensor service
Loaded: loaded (/etc/systemd/system/sonoffdiy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-08-12 09:36:51 CEST; 1 day 12h ago
Main PID: 30402 (code=exited, status=1/FAILURE)
août 12 09:36:48 raspberrypi systemd[1]: Started System Sensor service.
août 12 09:36:51 raspberrypi python3[30402]: sonoffdiy2mqtt.json can not be read! [Errno 2] No such file or directory: 'sonoffdiy2mqtt.json'
août 12 09:36:51 raspberrypi python3[30402]: Traceback (most recent call last):
août 12 09:36:51 raspberrypi python3[30402]: File "/home/pi/SRC/sonoffdiy2mqtt/sonoffdiy2mqtt.py", line 62, in <module>
août 12 09:36:51 raspberrypi python3[30402]: if ssettings["mqtt_type"]=="domoticz":
août 12 09:36:51 raspberrypi python3[30402]: TypeError: list indices must be integers or slices, not str
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Main process exited, code=exited, status=1/FAILURE
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Unit entered failed state.
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Failed with result 'exit-code'.
How to specified the path of sonoffdiy2mqtt.json in the python script ?
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
Interesting i did not experienced it. How fast did you click its icon in Domoticz?chatainsim wrote: ↑Tuesday 13 August 2019 21:49 I have some issue with the script.
Sometimes when I turn off the SonOff, it turn on again immediatly.
Same when I turn it on.
For MQTT I've setuped the Publish Topic to out, is it correct ?
Publish is "domoticz/in" and Subscribe is "domoticz/out" but if you set the type to "domoticz" and leave Pub&Sub empty it will auto-fill them on startup, if you define topics in the opposite way, it may cause some troubles.
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
The sonoffdiy2mqtt.json has to be located in the same directory as the sonoffdiy2mqtt.py. I guess that when the service starts the working directory is somewhere elsewhere, which i think i fixed in today commit.chatainsim wrote: ↑Tuesday 13 August 2019 21:52 août 12 09:36:48 raspberrypi systemd[1]: Started System Sensor service.
août 12 09:36:51 raspberrypi python3[30402]: sonoffdiy2mqtt.json can not be read! [Errno 2] No such file or directory: 'sonoffdiy2mqtt.json'
août 12 09:36:51 raspberrypi python3[30402]: Traceback (most recent call last):
août 12 09:36:51 raspberrypi python3[30402]: File "/home/pi/SRC/sonoffdiy2mqtt/sonoffdiy2mqtt.py", line 62, in <module>
août 12 09:36:51 raspberrypi python3[30402]: if ssettings["mqtt_type"]=="domoticz":
août 12 09:36:51 raspberrypi python3[30402]: TypeError: list indices must be integers or slices, not str
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Main process exited, code=exited, status=1/FAILURE
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Unit entered failed state.
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Failed with result 'exit-code'.[/code]
Failed to find the sonoffdiy2mqtt.json
How to specified the path of sonoffdiy2mqtt.json in the python script ?
https://github.com/enesbcs/sonoffdiy2mq ... 0c3bc7ea10
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
I've only clicked once. And set everything by default.lwolf wrote: ↑Tuesday 13 August 2019 22:13Interesting i did not experienced it. How fast did you click its icon in Domoticz?chatainsim wrote: ↑Tuesday 13 August 2019 21:49 I have some issue with the script.
Sometimes when I turn off the SonOff, it turn on again immediatly.
Same when I turn it on.
For MQTT I've setuped the Publish Topic to out, is it correct ?
Publish is "domoticz/in" and Subscribe is "domoticz/out" but if you set the type to "domoticz" and leave Pub&Sub empty it will auto-fill them on startup, if you define topics in the opposite way, it may cause some troubles.
It's only the Domoticz conf for mqtt I'm not sure which kind of Pub topic I should set. Out, / or both ?
Thanks
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
The Publish topic in Domoticz for the "MQTT Client Gateway" hardware is simple "out" this way the Domoticz publishing messages to domoticz/out topic which is the subscribe topic in the point of view of the sonoff, where it is receiving commands. Leaving "mqtt_topic_pub":"" and "mqtt_topic_sub":"" as empty is a good start point.chatainsim wrote: ↑Wednesday 14 August 2019 12:48 I've only clicked once. And set everything by default.
It's only the Domoticz conf for mqtt I'm not sure which kind of Pub topic I should set. Out, / or both ?
(Or you can try the shelly working-mode in which mode the topics are fixed so also can be left empty, altough an extra python plugin is needed, but there are no need of IDX creation as device detection is automatic.)
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
I confirm, it's fixed.lwolf wrote: ↑Tuesday 13 August 2019 22:25The sonoffdiy2mqtt.json has to be located in the same directory as the sonoffdiy2mqtt.py. I guess that when the service starts the working directory is somewhere elsewhere, which i think i fixed in today commit.chatainsim wrote: ↑Tuesday 13 August 2019 21:52 août 12 09:36:48 raspberrypi systemd[1]: Started System Sensor service.
août 12 09:36:51 raspberrypi python3[30402]: sonoffdiy2mqtt.json can not be read! [Errno 2] No such file or directory: 'sonoffdiy2mqtt.json'
août 12 09:36:51 raspberrypi python3[30402]: Traceback (most recent call last):
août 12 09:36:51 raspberrypi python3[30402]: File "/home/pi/SRC/sonoffdiy2mqtt/sonoffdiy2mqtt.py", line 62, in <module>
août 12 09:36:51 raspberrypi python3[30402]: if ssettings["mqtt_type"]=="domoticz":
août 12 09:36:51 raspberrypi python3[30402]: TypeError: list indices must be integers or slices, not str
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Main process exited, code=exited, status=1/FAILURE
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Unit entered failed state.
août 12 09:36:51 raspberrypi systemd[1]: sonoffdiy.service: Failed with result 'exit-code'.[/code]
Failed to find the sonoffdiy2mqtt.json
How to specified the path of sonoffdiy2mqtt.json in the python script ?
https://github.com/enesbcs/sonoffdiy2mq ... 0c3bc7ea10
Now it's working fine with systemd!
Thanks
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
I've setuped the Mqtt conf in Domoticz to Out.lwolf wrote: ↑Wednesday 14 August 2019 17:28The Publish topic in Domoticz for the "MQTT Client Gateway" hardware is simple "out" this way the Domoticz publishing messages to domoticz/out topic which is the subscribe topic in the point of view of the sonoff, where it is receiving commands. Leaving "mqtt_topic_pub":"" and "mqtt_topic_sub":"" as empty is a good start point.chatainsim wrote: ↑Wednesday 14 August 2019 12:48 I've only clicked once. And set everything by default.
It's only the Domoticz conf for mqtt I'm not sure which kind of Pub topic I should set. Out, / or both ?
(Or you can try the shelly working-mode in which mode the topics are fixed so also can be left empty, altough an extra python plugin is needed, but there are no need of IDX creation as device detection is automatic.)
And defined the ID of the Sonoff and IDX from Domoticz in json file.
But it's still sometimes turning it on again after a off and vice versa.
How can I degub the python script ?
Thanks
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
I've found a possible mqtt bounce error, however my test device did not turn on/off, but maybe it will help you.chatainsim wrote: ↑Wednesday 14 August 2019 18:56 I've setuped the Mqtt conf in Domoticz to Out.
And defined the ID of the Sonoff and IDX from Domoticz in json file.
But it's still sometimes turning it on again after a off and vice versa.
How can I degub the python script ?
Please download fresh code from github and retry.
From now if you are adding "debug":1, line to sonoffdiy2mqtt.json than state changing will be reported to the console.
-
- Posts: 101
- Joined: Wednesday 25 March 2015 10:46
- Target OS: Linux
- Domoticz version: v4.11307
- Location: France
- Contact:
Re: SONOFF BASICR3
Nice, it's working fine now.lwolf wrote: ↑Wednesday 14 August 2019 20:50I've found a possible mqtt bounce error, however my test device did not turn on/off, but maybe it will help you.chatainsim wrote: ↑Wednesday 14 August 2019 18:56 I've setuped the Mqtt conf in Domoticz to Out.
And defined the ID of the Sonoff and IDX from Domoticz in json file.
But it's still sometimes turning it on again after a off and vice versa.
How can I degub the python script ?
Please download fresh code from github and retry.
From now if you are adding "debug":1, line to sonoffdiy2mqtt.json than state changing will be reported to the console.
Thank you for the good job!
-
- Posts: 216
- Joined: Saturday 10 November 2018 18:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Hungary
- Contact:
Re: SONOFF BASICR3
No problem, thank you for your feedback.chatainsim wrote: ↑Thursday 15 August 2019 11:25 Nice, it's working fine now.
Thank you for the good job!
Who is online
Users browsing this forum: No registered users and 1 guest