i was working in android app but i don’t have android phone for now
you need to download this file
here
/custom_components/light
then
in your config file put this
light:
- platform: sonoff
host: “your hassio ip”
port: “1080”
This worked, although I did have the correct IP in my later test, I wonder if it’s more to do with keeping the formatting as raw and no spaces.
Any way this worked perfectly:
{"version":4,"ssid":"MYWIFI","password":"PASSWORD","serverName":"192.168.1.51","port":1081}
I don’t see custom_components in configurator, any ideas? Do I create this folder in the config folder or does it exist somewhere else?
if folder not exist create a new one
Does this need to be inside the config folder?
Got it, it needs creating in the config folder:
config/custom_components/sonoff.py
On a side note your vue admin page is great, just wondered is it possible to run this under https?
I’m also getting platform “sonoff” not found
Hi,
First, thank you for this post and what you created, it’s very useful even if it’s been quite a challenge for me.
So, I followed the instructions on the GitHub page, and I successfully installed Node Red, and the node-red-contrib-sonoff-server. So far so good, even if I struggled quite a bit.
One thing I can’t figure out though: How to access the sonoff server on :1080. I’ve configured it in node red and it seems to be working since I have:
Aug 22:41:29 - [info] [sonoff-server:xxxxxxxx.xxxxxx] SONOFF Server Started On Port 1080
However, when I try to access the server using my duckdns url (https://myserver.duckdns.org:1080), i get an empty response. On 1081, I get access refused.
Both port are forwarded to my pi’s address using TCP (not sure of the terminology here, I’m just a simple hobbyist).
Questions:
- Even if I haven’t got to the post request part with the sonoff, I should be able to access the server interface, right ?
- How to properly configure the sonoff server in node red ? I have no clue what the websocket value should be.
you don’t need node-red
/custom_components/light/sonoff.py
I’d just use the hassio sonoff server referred to in this thread. It works really well and there is a nice little UI to setup your devices.
You do need to be able to post the commands to your sonoff though. If you use the exact details with postman, as mentioned above you should be golden. Ensure you have your sonoff device in paring mode and you have connected to it as wifi access point, and the ip is 10.10.7.1 as mentioned above.
I’m getting the following error now, I can confirm I have a sonoff.devices.json and a sonoff.config.json.
Error while setting up platform sonoff
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/light/sonoff.py", line 43, in setup_platform
with open('/config/sonoff.ha.json') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/config/sonoff.ha.json'
Should I assume this is meant to be ‘/config/sonoff.devices.json’ in sonoff.py?
create a sonoff.ha.json in your config directory with the content of http://hassio.local:1080/hadevices
i will fix many issues soon
great thanks will give it a try
Error while setting up platform sonoff
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/light/sonoff.py", line 44, in setup_platform
for device in json.loads(f.read()):
File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.6/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 3 column 9 (char 16)
I guess I’ll need to tweak the json from that endpoint a little…
tomorrow i will publish a new update.
Thanks for your feedback !
I’m at the exact same point as you appear to be.
However, I still can’t see the sonoff on the :1080 interface. i’m using duckdns, so I guess I should put the address, without the port, under serverName in the post request, right ?
edit: After extensive research, i found this:
- The LED indicator quickly blinks twice and repeats, which means the device has connected to the router but fail to connect to the server.
Which is exactly what I have. So I guess it must be due to the fact that I’m using duckdns or something like that, my request must be messed up. Here’s what I’ve tried so far, maybe one of you guys will spot something obvious:
{“version”:4,“ssid”:“MySSID”,“password”:“MyPassword”,“serverName”:“https://REDACTED.duckdns.org”,“port”:1081}
Use your internal home assistant IP address. I’d love to be able to access the interface via HTTPS so I can make a panel quick link to it, but can’t see how to get it to serve as HTTPS. I noticed there is an SSL port of 1081, but that didn’t seem to work either.
Looking forward to the update, it seems so close! This is a really amazing feature for home assistant, I could see it being an integration at some point, like the Sonos or hue integrations.