nitaybz / homebridge-switcher-platform

Homebridge plugin for Switcher Smart Accessories
MIT License
35 stars 9 forks source link

Support the new Switcher Light devices #42

Closed gavrie closed 1 year ago

gavrie commented 1 year ago

I have installed a new Switcher Light SL02 device, and get the following message in a loop:

[5/9/2023, 3:59:26 PM] [Switcher Platform] Found New Switcher "Switcher Light_1135" | ID:f636c8 | IP: 192.168.68.66 | Model: UNKNOWN_0F05

Since lights are already supported as part of the Runner device, I guess this is just a matter of updating the list of supported devices?

gavrie commented 1 year ago

I tried to add it manually to the config as a switch, like this:

{
  "identifier": "Switcher Light_1135",
  "accessoryType": "switch"
}

But that fails because the device doesn't return a default_shutdown_seconds unlike other devices:

[5/9/2023, 4:31:20 PM] [Switcher Platform] Switcher "Switcher Light_1135" (f636c8) is Connected!

/usr/local/lib/node_modules/homebridge-switcher-platform/accessories/extras.js:9
                        this.accessory.context.duration = this.duration = this.state.default_shutdown_seconds
                                                                ^
TypeError: Cannot read properties of undefined (reading 'default_shutdown_seconds')
gavrie commented 1 year ago

It looks like the communication protocol is different for these devices:

[5/9/2023, 4:44:12 PM] [Switcher Platform] Received a message from New Device!!
[5/9/2023, 4:44:12 PM] [Switcher Platform] {
  device_id: 'f636c8',
  device_ip: '192.168.68.66',
  name: 'Switcher Light_1135',
  type: 'unknown_0f05',
  data_hex: 'fef0cf0004020200000000006a0e01000000f636c80000002b4e5a6400000000000000000000f0fe1d005377697463686572204c696768745f31313335000000000000000000000000000f0500c0a844423494549511350203030000000000025377697463686572204c696768745f31313335000000000000000000000000000204000045000100000000000500000044510100000000000000000006000000445101000000000000000000000000000000000000000000000000000000000000000000000000000000003e075906',
  data_str: '���\x00\x04\x02\x02\x00\x00\x00\x00\x00j\x0E\x01\x00\x00\x00�6�\x00\x00\x00+NZd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00��\x1D\x00Switcher Light_1135\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x05\x00��DB4�T�\x115\x02\x03\x03\x00\x00\x00\x00\x00\x02Switcher Light_1135\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x04\x00\x00E\x00\x01\x00\x00\x00\x00\x00\x05\x00\x00\x00DQ\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00DQ\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>\x07Y\x06'
}
gavrie commented 1 year ago

@nitaybz do you currently have any plans to support these devices? I thought of working on this myself if not.

nitaybz commented 1 year ago

@gavrie please check the recent version... I've added support but I don't have the device to test it

gavrie commented 1 year ago

Thanks @nitaybz! I just tested this, and it crashes:

[6/4/2023, 10:52:45 AM] [Switcher Platform] Found New Switcher "Switcher Run plus_28E8" | ID:c462c6 | IP: 192.168.68.61 | Model: S11
[6/4/2023, 10:52:45 AM] [Switcher Platform] Initializing Mixed Accessory - Switcher Run plus_28E8(id: c462c6)
[6/4/2023, 10:52:45 AM] [Switcher Platform] Switcher "Switcher Run plus_28E8" (c462c6) is Connected!

/usr/local/lib/node_modules/homebridge-switcher-platform/node_modules/switcher-js2/src/switcher.js:251
                                else if (device_type.include('sl')) {
                         ^
TypeError: device_type.include is not a function
    at Socket.<anonymous> (/usr/local/lib/node_modules/homebridge-switcher-platform/node_modules/switcher-js2/src/switcher.js:251:26)
    at Socket.emit (node:events:513:28)
    at UDP.onMessage (node:dgram:930:8)
[6/4/2023, 10:52:45 AM] [Switcher Platform] Child bridge process ended
[6/4/2023, 10:52:45 AM] [Switcher Platform] Process Ended. Code: 1, Signal: null
nitaybz commented 1 year ago

Latest version is not crashing but apparently I need to add this to the devices that are controlled with the token... will happen later today

nitaybz commented 1 year ago

try the latest

gavrie commented 1 year ago

@nitaybz Almost there... 😄 The status of the lights now shows correctly in Homebridge, but turning on/off does not work -- the commands are ignored.

BTW I did set the token in the config, and it works correctly with my S11 device.

nitaybz commented 1 year ago

will work now, try with the latest

gavrie commented 1 year ago

Woohoo, you did it! 🎉 Works perfectly now with v4.4.4. Thanks a lot @nitaybz!

gavrie commented 1 year ago

Oh, one last small thing: The lights show in Apple Home as switches and not as lights. It's not a problem since I can easily change the device type in the Home app, but it might be nice to have them show up as lights by default.

nitaybz commented 1 year ago

I rather save the flexibility as having this as switch so it can be changed to fan if needed or any other "Switch" which is not necessarily lights like toilet venta