NSPManager / NSPanelManager

Sonoff NSPanel custom firmware for responsive and intuitive use
https://discord.gg/RwXvAH56fE
153 stars 11 forks source link

Update Add lights window to support Switches #6

Closed cablesandcoffee closed 1 year ago

cablesandcoffee commented 1 year ago

Current behaviour Currently an Openhab user is able to add a light that is of type Switch in the Add lights window but Openhab throws an error when NSPM is sending a percent value to the switch and the light is neither turned on or off.

Error from Openhab log: [hab.core.io.websocket.EventWebSocket] - Failed to process deserialized event '{"type": "ItemCommandEvent", "topic": "openhab/items/Outlet2LightsMirror_Brightness/command", "payload": "{\"type\":\"Percent\",\"value\":\"0\"}", "source": "WebSocketNSPanelManager"}': Incompatible datatype, rejected.

Expected Behaviour If brightness slider > 0 a light of type Switch should turn on If brightness slider = 0 light of type Switch should turn off

Solution: Add "Switch" as capability in Add lights window to know when to use the payload shown below.

For switches the payload sent on Openhab websocket must look like this: "payload": "{\"type\":\"OnOff\",\"value\":\"ON\"}"

tpanajott commented 1 year ago

This should work as of commit 7728d939cb8d5ea881a9acd4778a080784f17fe4 but it requires further testing/verification

cablesandcoffee commented 1 year ago

I can see that the add light window has been updated but it does not seem to work perfectly just yet. It looks like this:

Screenshot from 2023-03-26 18-37-25

The switch item is presented in Dimming , Color and RGB drop downs but not in Switch drop down. Get error when trying to add light as well:

Screenshot from 2023-03-26 18-39-05

tpanajott commented 1 year ago

Try clearing the browser cache by holding shift while pressing the "reload"-button. That should fix the issue with the drop-down not populating.

tpanajott commented 1 year ago

Tested this issue using the latest code and can add lights as switches without it crashing. This requires more information. Can you please provide the whole page for the error?

cablesandcoffee commented 1 year ago

Works after clearing cache. No issues with adding lights so everything seems solved.