make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.31k stars 513 forks source link

New device request: Space Dog Music Lamp #333

Closed and7ey closed 1 year ago

and7ey commented 1 year ago

Here is the device: https://aliexpress.ru/item/1005003985474315.html

Device matches rgbcw_lightbulb with quality of 28%. DPS: {'updated_at': 1672688732.0740755, '20': True, '21': 'white', '22': 1000, '24': '012c03e803e8', '26': 0, '102': True, '103': False, '104': '3', '105': True, '106': False, '107': '013000', '108': '5', '109': 100, '110': False, '111': '24', '114': False, '115': True, '116': 1000}

I've drafted the yaml, but some corrections are needed there:

OUTDATED YAML

```yaml name: Space Dog Music Lamp primary_entity: entity: light dps: # ON/OFF # values: ON, OFF - id: 20 type: boolean name: switch # Mode # values: White, Scene, Music, Color - id: 21 type: string name: color_mode mapping: - dps_val: White value: color_temp - dps_val: Color value: rgbw # Brightness # values: 1000, 400 - id: 22 name: brightness type: integer range: min: 10 max: 1000 mapping: # do I need it? - scale: 3.92 # Color # sample values: 00f003e803e8, 00b403e803e8, 000003e803e8, 00f003e803e8 - id: 24 name: rgbhsv type: hex format: - name: h bytes: 2 range: min: 0 max: 360 - name: s bytes: 2 range: min: 0 max: 1000 - name: v bytes: 2 range: min: 0 max: 1000 # Ocean Wave switch # values: Ocean Wave On, Ocean Wave Off - id: 102 type: boolean name: switch # Ocean Wave breathing switch # values: Ocean Wave breathing OFF, Ocean Wave breathing ON - id: 103 type: boolean name: switch # Moire speed # values: horotelic, fast - id: 104 # laser switch # values: laser off, laser on - id: 105 type: boolean name: switch # Laser breather switch # values: Laser breather off, Laser breather on - id: 106 type: boolean name: switch # Local music control # values: 010001 (minimum volume), 016401 (maximum volume), 001e00 (previous song), 011e00 (next song), 023900, 023500, 033500, 033900, 033c00, 034000, 034300, 034700, 034b00, 034e00 # looks like two values are combined there - volume and song id (?) - id: 107 # 本地音乐风格 (local music style / rhythm scenes) # values: 1 (rock), 2 (jazz), 3 (classical), 4 (ball game), 5 (game) - id: 108 # 麦克风灵敏度 (Microphone sensitivity) # values: 100, 60, 0 - id: 109 type: integer range: min: 0 max: 100 # Microphone switch # values: Microphone off, Microphone on - id: 110 type: boolean name: switch # 场景 (scenes) # values: see below - id: 111 type: hex name: effect mapping: - dps_val: 00 value: Passion - Single colors - dps_val: 01 value: Passion - Mixed colors - dps_val: 02 value: Passion - Multi colors - dps_val: 03 value: Nature - Spring - dps_val: 04 value: Nature - Summer - dps_val: 05 value: Nature - Autumn - dps_val: 06 value: Nature - Winter - dps_val: 07 value: Nature - Coral Red - dps_val: 08 value: Nature - Tangerine - dps_val: 09 value: Nature - Light Yellow - dps_val: 0a value: Nature - Emerald - dps_val: 0b value: Nature - Aquamarine - dps_val: 0c value: Nature - Dodger Blue - dps_val: 0d value: Nature - Violet - dps_val: 0e value: Midley - Dynamic - dps_val: 0f value: Midley - Prairie - dps_val: 10 value: Midley - Multi-colors - dps_val: 11 value: Midley - Splendid - dps_val: 12 value: Midley - Gorgeous - dps_val: 13 value: Midley - Blue Sky - dps_val: 14 value: Midley - Sunrise - dps_val: 15 value: Midley - Sunset - dps_val: 16 value: Midley - Ocean - dps_val: 17 value: Midley - Forest - dps_val: 18 value: Midley - Campfire - dps_val: 19 value: Midley - Strobe - dps_val: 1a value: Midley - Pulse - dps_val: 1b value: Midley - Breathing - dps_val: 1c value: Midley - Dreamlike - dps_val: 1d value: Midley - Mediterranean - dps_val: 1e value: Midley - Flashing - dps_val: 1f value: Midley - Romance - dps_val: 20 value: Midley - Passion - dps_val: 21 value: Midley - Soft - dps_val: 22 value: Midley - Peace - dps_val: 23 value: Midley - Leasure - dps_val: 24 value: Festival - Birthday - dps_val: 2d value: Theme - Romance - dps_val: 2e value: Theme - Gallop - dps_val: 2f value: Theme - Motivated # White light independent switch # values: ON, OFF - id: 114 type: boolean name: switch # Color light independent switch # values: ON, OFF - id: 115 type: boolean name: switch # The laser intensity # values: 0..1000 - id: 116 type: integer range: min: 10 max: 1000 # adjust # values: (no records found) # - id: 117 secondary_entities: - entity: number name: Timer category: config icon: "mdi:timer" dps: - id: 26 name: value type: integer range: min: 0 max: 86400 unit: min mapping: - scale: 60 step: 60 optional: true ```

and7ey commented 1 year ago

Here is the working config:

YAML

```yaml name: Space Dog Music Lamp primary_entity: entity: light icon: "mdi:dog-side" dps: # ON/OFF # values: ON, OFF - id: 20 type: boolean name: switch # Mode # values: White, Scene, Music, Color - id: 21 type: string name: color_mode mapping: - dps_val: white value: color_temp - dps_val: colour value: rgbw - dps_val: scene value: colorloop - dps_val: music value: random # Brightness # values: 1000, 400 - id: 22 name: brightness type: integer range: min: 10 max: 1000 mapping: # do I need it? - scale: 3.92 # Color # sample values: 00f003e803e8, 00b403e803e8, 000003e803e8, 00f003e803e8 - id: 24 name: rgbhsv type: hex format: - name: h bytes: 2 range: min: 0 max: 360 - name: s bytes: 2 range: min: 0 max: 1000 - name: v bytes: 2 range: min: 0 max: 1000 # Moire speed # values: horotelic, fast # - id: 104 # type: string # name: moire # mapping: # - dps_val: horotelic # value: Horotelic # - dps_val: fast # value: Fast # Local music control # values: 010001 (minimum volume), 016401 (maximum volume), 001e00 (previous song), 011e00 (next song), 023900, 023500, 033500, 033900, 033c00, 034000, 034300, 034700, 034b00, 034e00 # looks like two values are combined there - volume and song id (?) # - id: 107 # 场景 (scenes) # values: see below - id: 111 type: hex name: effect optional: true mapping: - dps_val: 00 value: Passion - Single colors - dps_val: 01 value: Passion - Mixed colors - dps_val: 02 value: Passion - Multi colors - dps_val: 03 value: Nature - Spring - dps_val: 04 value: Nature - Summer - dps_val: 05 value: Nature - Autumn - dps_val: 06 value: Nature - Winter - dps_val: 07 value: Nature - Coral Red - dps_val: 08 value: Nature - Tangerine - dps_val: 09 value: Nature - Light Yellow - dps_val: 0a value: Nature - Emerald - dps_val: 0b value: Nature - Aquamarine - dps_val: 0c value: Nature - Dodger Blue - dps_val: 0d value: Nature - Violet - dps_val: 0e value: Midley - Dynamic - dps_val: 0f value: Midley - Prairie - dps_val: 10 value: Midley - Multi-colors - dps_val: 11 value: Midley - Splendid - dps_val: 12 value: Midley - Gorgeous - dps_val: 13 value: Midley - Blue Sky - dps_val: 14 value: Midley - Sunrise - dps_val: 15 value: Midley - Sunset - dps_val: 16 value: Midley - Ocean - dps_val: 17 value: Midley - Forest - dps_val: 18 value: Midley - Campfire - dps_val: 19 value: Midley - Strobe - dps_val: 1a value: Midley - Pulse - dps_val: 1b value: Midley - Breathing - dps_val: 1c value: Midley - Dreamlike - dps_val: 1d value: Midley - Mediterranean - dps_val: 1e value: Midley - Flashing - dps_val: 1f value: Midley - Romance - dps_val: 20 value: Midley - Passion - dps_val: 21 value: Midley - Soft - dps_val: 22 value: Midley - Peace - dps_val: 23 value: Midley - Leasure - dps_val: 24 value: Festival - Birthday - dps_val: 2d value: Theme - Romance - dps_val: 2e value: Theme - Gallop - dps_val: 2f value: Theme - Motivated # adjust # values: (no records found) # - id: 117 secondary_entities: - entity: number name: Timer category: config icon: "mdi:timer" dps: - id: 26 name: value optional: true type: integer range: min: 0 max: 86400 unit: min mapping: - scale: 60 step: 60 - entity: switch name: Laser icon: "mdi:laser-pointer" dps: # laser switch # values: laser off, laser on - id: 105 name: switch type: boolean optional: true - entity: switch name: Laser breather icon: "mdi:laser-pointer" dps: # values: Laser breather off, Laser breather on - id: 106 name: switch type: boolean optional: true - entity: number name: Laser intensity icon: "mdi:laser-pointer" # The laser intensity # values: 0..1000 dps: - id: 116 name: value type: integer range: min: 0 max: 1000 - entity: switch name: Ocean Wave icon: "mdi:waves" dps: # values: Ocean Wave On, Ocean Wave Off - id: 102 name: switch type: boolean optional: true - entity: switch name: Ocean Wave breathing icon: "mdi:waves" dps: # values: Ocean Wave breathing OFF, Ocean Wave breathing ON - id: 103 name: switch type: boolean optional: true - entity: switch name: Microphone icon: "mdi:microphone" dps: - id: 110 name: switch type: boolean optional: true mapping: - dps_val: true value: true icon: "mdi:microphone" - dps_val: false value: false icon: "mdi:microphone-off" - entity: number name: Microphone sensitivity icon: "mdi:microphone-settings" # 麦克风灵敏度 (Microphone sensitivity) # values: 100, 60, 0 dps: - id: 109 name: value type: integer range: min: 0 max: 100 - entity: switch name: White light icon: "mdi:lightbulb" dps: # values: ON, OFF - id: 114 name: switch type: boolean optional: true - entity: switch name: Color light icon: "mdi:lightbulb" dps: # values: ON, OFF - id: 115 name: switch type: boolean optional: true - entity: select name: Rhythm scenes icon: "mdi:music" # 本地音乐风格 (local music style / rhythm scenes) # values: 1 (rock), 2 (jazz), 3 (classical), 4 (ball game), 5 (game) dps: - id: 108 type: integer name: option optional: true mapping: - dps_val: 1 value: Rock - dps_val: 2 value: Jazz - dps_val: 3 value: Classical - dps_val: 4 value: Ball game - dps_val: 5 value: Game ```

The following minor questions are left:

  1. don't understand how to switch to Music mode thru HA interface
  2. Local music control is not implemented
  3. not sure if Rhythm scenes work - it shows empty value and change of the value is not reflected in the original app
  4. not sure if microphone on/off icon works correctly
make-all commented 1 year ago

Your detection log above lists all the dps, why have so many been marked as optional? Probably it is this that is preventing the Rhythm selection from working.

make-all commented 1 year ago
  1. I moved the scene selection from an explicit "effect" dp to a separate select entity, so that the extra color_mode settings are exposed as effects. I also renamed them to Scene and Music rather than trying to reuse Home Assistant's predefined effect names of colorloop and random, as there doesn't seem to be any special handling of those predefined values to give any benefit (except maybe the new translation ability in 2023.1 will bring translations predefined values within HA sooner than will otherwise happen).
  2. This looks complex, you could still expose it as an attribute that can be monitored.
  3. As above, this may be because the dp is optional, and when not in the underlying data may be causing the entity to stop working.
  4. I have rearranged the icon logic, due to setting at two levels (top level and dp value based), without icon_priority being set the behaviour may not be predictable. Instead I moved the false condition to a default condition, and removed the top level icon setting (I chose false as the default, because if this optional dp is missing, it most likely means that the mic is off (or more accurately the light is in some mode where it will not use the mic)
make-all commented 1 year ago

I also notice a commented out Moire speed, which is present in the detection log. As with the Rhythm scene, it appears to be implemented in the local protocol as a number string rather than spelt out in words. So you would need to find the values it uses (only two options are listed in the commented out config, but the current value in the log is "3", so maybe there are more options).

and7ey commented 1 year ago

Thanks for your corrections.

Rhythm works well now. Moire speed options: stop, slow, horotelic and fast.

The most confusion part is about effects. Looks like it worked well with my config, but with your config when I just open the entity in HA, it changes to another tab in the original app and the effect is not applied. I think when it is used as effect and I choose the value, it changes the Mode also. And it doesn't happen with your config. Suggest to move it back to effects.

and7ey commented 1 year ago

@make-all sorry for off top - do you see my comments for closed issue about screen sync device? ;)

make-all commented 1 year ago

The changes I made to your config are:

There is no logic that would automatically change a mode with the old config, but not with the new config, so I am having trouble understanding your issue, besides the fact that the music and scene are now exposed while they weren't before.

Regarding the closed issue, the last comment there just reinforces why it was the correct decision to not pretend it is possible to support this device.

and7ey commented 1 year ago

Looks like there is no need to change the Mode manually.

Scene and Music values are useless. They do just nothing.

I don't know why, but my version of the config works perfectly, when yours is having some troubles. Suggest just to add rhythm (and probably Moire speed) to my config.

With regards to the closed issue: I faced with such strange value 2nd time since I've started my experiments. I think it is better to have the device, which works in 99,9% cases than not to have it at all. Wrong values you may consider like network connection problem, which happens in some rare cases.

make-all commented 1 year ago

As per the comment on #309, this should now be working correctly with the current config. I am not sure why your previous config was working, as it seems that to support scenes in Tuya lights, you need to be able to explicitly set the "color_mode" dp to "scene", but the code to set color_mode based on effects was effectively unreachable.

make-all commented 1 year ago

Closing as this was already fixed in a previous release