bewee / tuya-adapter

GNU General Public License v3.0
8 stars 8 forks source link

Dimmer for Jackyled plug #6

Closed LionMike closed 4 years ago

LionMike commented 4 years ago

Added Jackyled plug with two sockets and night light. When configured as 3-gang switch, night light is on/off. When configured as thing, night light has brightness 0-255

bewee commented 4 years ago

Please do the following: Turn device type to (empty). Then send a screenshot of the device view. Please also describe what happens when you enter different values to the inputs you see there.

LionMike commented 4 years ago

Screenshot_2020-04-17 WebThings Gateway

checking box 1 and 2 turns on sockets. checking box 3 turns on light. Changing values on 103 from 0 to 255 adjusts brightness of light with 0 being completely off.

(2020-04-17 15:07:58.619 INFO : tuya-adapter: setCachedValueAndNotify for property 3 from true to false for tuya-54771532840d8e4ae6bf 2020-04-17 15:07:58.620 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/3 Execute tuyapi command { dps: '3', set: false } 2020-04-17 15:07:58.668 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf Data { devId: '54771532840d8e4ae6bf', 2020-04-17 15:07:58.669 INFO : tuya-adapter: dps: { '3': false }, 2020-04-17 15:07:58.670 INFO : tuya-adapter: t: 1587154078, 2020-04-17 15:07:58.672 INFO : tuya-adapter: s: 23 } 2020-04-17 15:07:58.673 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/3 update( false ) 2020-04-17 15:07:58.674 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf Data { devId: '54771532840d8e4ae6bf', 2020-04-17 15:07:58.675 INFO : tuya-adapter: dps: { '3': false }, 2020-04-17 15:07:58.676 INFO : tuya-adapter: t: 1587154078, 2020-04-17 15:07:58.677 INFO : tuya-adapter: s: 23 } 2020-04-17 15:07:58.682 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/3 update( false ) 2020-04-17 15:07:58.684 INFO : tuya-adapter: Thing updated tuya-54771532840d8e4ae6bf 2020-04-17 15:07:58.911 INFO : getValue for property 1 for: Jackyled 1 returning true 2020-04-17 15:07:58.913 INFO : getValue for property 2 for: Jackyled 1 returning true 2020-04-17 15:07:58.915 INFO : getValue for property 3 for: Jackyled 1 returning false 2020-04-17 15:07:58.917 INFO : getValue for property 103 for: Jackyled 1 returning 255 2020-04-17 15:08:00.621 INFO : tuya-adapter: setCachedValueAndNotify for property 3 from false to true for tuya-54771532840d8e4ae6bf 2020-04-17 15:08:00.623 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/3 Execute tuyapi command { dps: '3', set: true } 2020-04-17 15:08:00.793 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf Data { devId: '54771532840d8e4ae6bf', 2020-04-17 15:08:00.795 INFO : tuya-adapter: dps: { '3': true }, 2020-04-17 15:08:00.797 INFO : tuya-adapter: t: 1587154080, 2020-04-17 15:08:00.799 INFO : tuya-adapter: s: 24 } 2020-04-17 15:08:00.801 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/3 update( true ) 2020-04-17 15:08:00.803 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf Data { devId: '54771532840d8e4ae6bf', 2020-04-17 15:08:00.804 INFO : tuya-adapter: dps: { '3': true }, 2020-04-17 15:08:00.805 INFO : tuya-adapter: t: 1587154080, 2020-04-17 15:08:00.806 INFO : tuya-adapter: s: 24 } 2020-04-17 15:08:00.807 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/3 update( true ) 2020-04-17 15:08:00.808 INFO : tuya-adapter: Thing updated tuya-54771532840d8e4ae6bf 2020-04-17 15:08:00.809 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf Data { devId: '54771532840d8e4ae6bf', 2020-04-17 15:08:00.810 INFO : tuya-adapter: dps: { '103': 255 }, 2020-04-17 15:08:00.811 INFO : tuya-adapter: t: 1587154080, 2020-04-17 15:08:00.813 INFO : tuya-adapter: s: 25 } 2020-04-17 15:08:00.814 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/103 update( 255 ) 2020-04-17 15:08:00.826 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf Data { devId: '54771532840d8e4ae6bf', 2020-04-17 15:08:00.827 INFO : tuya-adapter: dps: { '103': 255 }, 2020-04-17 15:08:00.828 INFO : tuya-adapter: t: 1587154080, 2020-04-17 15:08:00.828 INFO : tuya-adapter: s: 25 } 2020-04-17 15:08:00.829 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/103 update( 255 ) 2020-04-17 15:08:00.830 INFO : tuya-adapter: Thing updated tuya-54771532840d8e4ae6bf 2020-04-17 15:08:01.097 INFO : getValue for property 1 for: Jackyled 1 returning true 2020-04-17 15:08:01.098 INFO : getValue for property 2 for: Jackyled 1 returning true 2020-04-17 15:08:01.099 INFO : getValue for property 3 for: Jackyled 1 returning true 2020-04-17 15:08:01.100 INFO : getValue for property 103 for: Jackyled 1 returning 255 2020-04-17 15:08:01.435 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: even = True (False) 2020-04-17 15:08:01.440 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: minute = 8 (7)

bewee commented 4 years ago

That's quite an interesting piece of hardware^^ 204ce36b1f71b620bf5cf5ef5756c1c89fbc4b82 added support for this device Please clone the latest state of this repository, select device type "Plug with night light" and config {"dps":{"brightness":103},"sockets":2,"minbrightness":1,"maxbrightness":255} and report back whether this works.

LionMike commented 4 years ago

That almost worked. However the configuration is backward. On/Off Light is plug one, on/off 1 is plug two, and on/off 2 is light. I also lost the 2-gang, 3-gang, and 4-gang choices in type selection.

020-04-18 09:17:06.378 INFO : tuya-adapter: setCachedValueAndNotify for property brightness from 100 to 0 for tuya-54771532840d8e4ae6bf 2020-04-18 09:17:06.380 INFO : tuya-adapter: tuya-54771532840d8e4ae6bf/brightness Execute tuyapi command { dps: 103, set: 1 } 2020-04-18 09:18:01.543 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: even = True (False) 2020-04-18 09:18:01.549 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: minute = 18 (17) 2020-04-18 09:19:01.636 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: even = False (True) 2020-04-18 09:19:01.642 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: minute = 19 (18) 2020-04-18 09:20:01.728 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: even = True (False) 2020-04-18 09:20:01.734 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: minute = 20 (19) 2020-04-18 09:20:01.736 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: minutes5 = 20 (15) 2020-04-18 09:21:01.824 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: even = False (True) 2020-04-18 09:21:01.831 INFO : date-time-adapter: date_property.py:53 DEBUG Device: DateTime Property: minute = 21 (20)

bewee commented 4 years ago

Does your logfile contain this line (or similar)? saveOwnConfig( {"dps":{"brightness":103,"on_light":3,"on1":1,"on2":2},"sockets":2,"minbrightness":1,"maxbrightness":255} ) As you can see, on1 is mapped to dps 1, on2 is mapped to dps 2 and on_light is mapped to dps 3. This matches exactly the behaviour you described earlier

checking box 1 and 2 turns on sockets. checking box 3 turns on light

bewee commented 4 years ago

I also lost the 2-gang, 3-gang, and 4-gang choices in type selection.

You can set the number of gangs/sockets using the config parameter of the device, see README.md. To my mind that's more elegant than having a huge lot of different devices that only differ in one parameter.

LionMike commented 4 years ago

saveOwnConfig( {"dps":{"brightness":103,"on_light":1,"on1":2,"on2":3},"sockets":2,"minbrightness":1,"maxbrightness":255} )

bewee commented 4 years ago

Please overwrite the config property of the device with exactly the value from README.md: {"dps":{"brightness":103},"sockets":2,"minbrightness":1,"maxbrightness":255}

LionMike commented 4 years ago

I changed configuration as written in README.md. After saving and using the plug it would revert back to the configuration I noted above. So I changed the config to: {"dps":{"brightness":103,"on_light":3,"on1":1,"on2":2},"sockets":2,"minbrightness":1,"maxbrightness":255} which is the configuration you expected to see in the log file. It works expected with that config.

bewee commented 4 years ago

Ok, that's weird. When I add the device with the mentioned configuration and then use it, it turns to what I wrote. Anyway, since it functions properly now, I will close this issue.