homemate-bridge icon indicating copy to clipboard operation
homemate-bridge copied to clipboard

Works with the S31!

Open boojew opened this issue 6 years ago • 22 comments

Just an FYI, without any mods, I got this to work with the S31!

One (quick?) request, would it be possible for you to make it possible to pass the docker container the mqtt parameters instead of having to fiddle with the downloaded hassdevice config file?If not, no worries!

What's interesting is that this model supports energy monitoring, but doesnt seem homemate can currently handle that..

boojew avatar Jan 26 '19 04:01 boojew

Edit: Nope, I was not patient enough..

`2019-01-25 23:39:01,753 - b'458nlc0757rhtmor3vn3n5qm4vrsc9yj' sent payload: {'cmd': 127, 'serial': 18, 'uid': '2c3ae82f88b2', 'timestamp': 1548477541, 'energy': '0.85'}

Wow! Awesome. I assume that this is not being sent to HASS as I don't THINK the mqtt switch accepts energy as a parameter.. Likely a separate sensor would need to be built that.

What is also strange is that energy doesnt seem to be published to the mqtt stream quite as often as I would expect. When using the app it is pretty fast to update. In this scenario, it seems to publish fairly randomly.. I wonder if there is a message to send to provocate the switch to send energy data more frequently.

boojew avatar Jan 26 '19 04:01 boojew

Awesome! Nice find!

You are correct, the energy parameter isn't going to get passed to Home Assistant; in theory this shouldn't be too hard to get set up, but in practice... the MQTT abstraction code is a complete mess, and I've been meaning to clean it up for about a year now.

You should be able to configure everything by passing environment variables, whatever you would pass via the command line, make it all caps, and replace - with _ (so --mqtt-host becomes MQTT_HOST etc)

insertjokehere avatar Jan 26 '19 05:01 insertjokehere

A clear sign I was tired - I didn’t even try environment variables. Ok cool. Will try tonight.

I’ll try and see what I can figure out with MQTT. I’m a bit of a MQTT noob. I’m python isn’t that much better either, but hopefully I can get this going. :)

On Sat, Jan 26, 2019 at 12:24 AM Will Hughes [email protected] wrote:

Awesome! Nice find!

You are correct, the energy parameter isn't going to get passed to Home Assistant; in theory this shouldn't be too hard to get set up, but in practice... the MQTT abstraction code is a complete mess, and I've been meaning to clean it up for about a year now.

You should be able to configure everything by passing environment variables, whatever you would pass via the command line, make it all caps, and replace - with _ (so --mqtt-host becomes MQTT_HOST etc)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/insertjokehere/homemate-bridge/issues/3#issuecomment-457803696, or mute the thread https://github.com/notifications/unsubscribe-auth/AA9_Dl2jtHLzQp_CRfVeDzr0vFPWzQpMks5vG-aWgaJpZM4aT_PB .

boojew avatar Jan 26 '19 17:01 boojew

@insertjokehere awesome work on this. Confirmed working on my s31's as well. The easiest way I found after running the script was to put the device in pairing mode and attempt to add it in the homebridge app. @boojew Did you figure anything out to pass the power data to HA over mqtt?

mssmison avatar Feb 10 '19 02:02 mssmison

Yea and no. I have an open PR that will intercept the data and send it over mqtt, but it seems s31 only sends it on a useful frequency when the app tells it too, so I need to figure out how to send the command for that

boojew avatar Feb 10 '19 13:02 boojew

Sounds like you've got a great start and idea as to where to go I'm happy to help with any packet captures from the app. Just let me know

mssmison avatar Feb 10 '19 16:02 mssmison

Got this to work with homebridge too. Just waiting for @boojew to finish his modifications for his pull request to incorporate the energy monitoring.

mkormendy avatar May 28 '19 15:05 mkormendy

@mkormendy getting it work with project required a (very) minor rewrite of an upstream library that insertjokehere maintains, but didnt want to immediately change. Meantime, I published this container with my changes https://hub.docker.com/r/boojew/homemate-bridge. I havent updated the main page at all.. sorry. There are 4 issues that I am aware and I documented them here https://github.com/boojew/homemate-bridge/issues. I will get around to fixing them soon. I hope.

boojew avatar Jun 06 '19 02:06 boojew

LoL. No worries. This is github!

mkormendy avatar Jun 06 '19 03:06 mkormendy

@mkormendy I have updated the container to work now properly as an energy sensor... but for some reason I broke the switch functionality... and I am really not sure why.. but in the meantime while I figure that out, if you want an energy sensor, there you go :)

boojew avatar Jun 11 '19 02:06 boojew

LMAO... well I appreciate your silver lining perspective :-) I think I'll wait, as I need the switch more than the sensor, it's just an added convenience.

mkormendy avatar Jun 11 '19 02:06 mkormendy

Actually - I think it may be an issue with my switch. I reverted back to @insertjokehere's container and I have the same issue. If you wouldnt mind trying mine, I wold be curious to see if it works

boojew avatar Jun 11 '19 03:06 boojew

I think it’s the MQTT broker. My devices that rely on MQTT have suddenly stopped working. What MQTT broker are you using?

mkormendy avatar Jun 12 '19 22:06 mkormendy

I'm using Mosca. I'm also using several services publishing to it and I havent seen any issues with them

boojew avatar Jun 13 '19 01:06 boojew

I'm using Mosquitto .. any reason why you use Mosca? (just curious)

mkormendy avatar Jun 13 '19 03:06 mkormendy

Using it because it was part of my setup from a while back - and honestly never had a need to change :)

I think I found the problem with my code. I'll try and test more later this week. Still not sure why or how this would kill your mqtt bridge

boojew avatar Jun 13 '19 04:06 boojew

Determined nothing killed the mqtt bridge, realized it was the homemate_bridge that kept reporting an exception and wouldn't process any more commands:

----------------------------------------
Exception happened during processing of request from ('192.168.2.102', 31490)
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.7/site-packages/homemate_bridge/cli.py", line 180, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/local/lib/python3.7/site-packages/homemate_bridge/cli.py", line 242, in handle
    data = self.request.recv(1024).strip()
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------

Restarting the bridge fixed the problem. I'm trying to figure out how to restart the bridge when it reports this exception on an automatic basis.

mkormendy avatar Jun 17 '19 02:06 mkormendy

Thanks! This is super useful feedback- it basically echos what I realized - the mqtt code is broken. My assumption now is that (atleast in the containerized version) it’s due to a dependency having been updated. I just haven’t had time to dig further. Maybe later this week.

On Sun, Jun 16, 2019 at 10:38 PM Mike Kormendy [email protected] wrote:

Found it that nothing killed the mqtt bridge. But realized it was the homemate_bridge that kept reporting an exception and wouldn't process any more commands:


Exception happened during processing of request from ('192.168.2.102', 31490) Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/lib/python3.7/site-packages/homemate_bridge/cli.py", line 180, in init super().init(*args, **kwargs) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in init self.handle() File "/usr/local/lib/python3.7/site-packages/homemate_bridge/cli.py", line 242, in handle data = self.request.recv(1024).strip() ConnectionResetError: [Errno 54] Connection reset by peer

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/insertjokehere/homemate-bridge/issues/3?email_source=notifications&email_token=AAHX6DX6LNOVRINEJD6GFEDP232LZA5CNFSM4GSP6PA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXZ4KGY#issuecomment-502514971, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHX6DQWR5LHP2TOEAVRVULP232LZANCNFSM4GSP6PAQ .

boojew avatar Jun 17 '19 03:06 boojew

I also reported another exception in a different issue/ticket here on @insertjokehere's repo.

mkormendy avatar Jun 17 '19 03:06 mkormendy

@boojew any update on that dependency issue?

mkormendy avatar Dec 17 '19 13:12 mkormendy

Just another happy S31/homeassistant user checking in here— thanks for making this available and for the super easy and clear setup instructions!

mikepurvis avatar Jun 10 '20 13:06 mikepurvis

Just another happy S31/homeassistant user checking in here— thanks for making this available and for the super easy and clear setup instructions!

Did you use the docker container to set this up? If so what does your docker command look like?

mike391 avatar Sep 27 '21 21:09 mike391