aronsky / esphome-components

Custom components for ESPHome
MIT License
45 stars 40 forks source link

Custom Command Service not working properly on lampsmart_pro v3 ? #27

Open mickabrig7 opened 1 month ago

mickabrig7 commented 1 month ago

Hi there, and thank you immensely for your work !

I have random Amazon ceiling lights that I'm able to control perfectly with this component, and lately I've been looking into adding RGB functionality through the Custom Command Service + a template light (I'll share the commands and args if this ends up working, if you want to add this to the component directly).

Only problem is, whichever parameters I use for the service call, I always get the same error in my node's logs: [W][ble_adv_controller:116]: Unsupported command received: 3. Aborted.

And here's how my controller is configured:

# Ceiling Lights
ble_adv_controller:
  - id: ceiling_light_controller
    encoding: lampsmart_pro
    variant: v3
    forced_id: 1
    reversed: true
    show_config: false

Do you think this is a bug with the lampsmart_pro encoding, or did I miss something obvious ?

aronsky commented 1 month ago

It seems that only commands that are already supported in code can be used. This feature is useful for sending arbitrary argument values, not arbitrary (unsupported) commands.

However, I agree that allowing arbitrary commands could be useful for extending support for additional devices/features. If you feel like adding such a capability via a pull request, that could be great!

mickabrig7 commented 1 month ago

Thanks for the quick reply ! Unless I'm doing something wrong, none of the commands work and they all result in the error code I copied, even the supported ones :thinking:

I tried switching to fanlamp_pro encoding as well as different variants, but the behavior is always the same. It feels like something is just broken on the receiving end, as the error code seems to report a cmd value of 3 no matter what I input.

It seems like this service was implemented by @NicoIIT in https://github.com/aronsky/esphome-components/pull/17, I'll try and see if a later commit breaks it !

(as a side note, in case it might be interesting to someone else, I was able to find that the RGB command on my device is 0x22 with args 1..3 as red, green and blue)

NicoIIT commented 1 month ago

Hi guys, I think I broke that in one of the last changes included in https://github.com/aronsky/esphome-components/pull/17.

Let me check if I repaired it already in my dev branch or if it is pending on my side.

EDIT: it should work with the main branch on my fork source: github://NicoIIT/esphome-components. The parameters should be:

mickabrig7 commented 1 month ago

Merci copain t'es trop fort c:

Everything works great, I just had to explicitly add ble_adv_handler to the external_components call using your fork, since you separated them.

Here's my ESPHome configuration:

external_components:
  - source: github://NicoIIT/esphome-components@main
    components: [ ble_adv_controller, ble_adv_handler ]

# Ceiling Lights
ble_adv_controller:
  - id: ceiling_light_controller
    encoding: lampsmart_pro
    variant: v3
    forced_id: 1
    reversed: true
    show_config: false

light:
  - platform: ble_adv_controller
    ble_adv_controller_id: ceiling_light_controller
    name: "Ceiling Light"

And in my configuration.yaml:

light:
  - platform: template
    lights:
      rgb_bedroom_ceiling_light:
        friendly_name: "Bedroom Ceiling Light"
        turn_on:
          - service: light.turn_on
            data:
              entity_id: light.bedroom_ceiling_light
        turn_off:
          - service: light.turn_off
            data:
              entity_id: light.bedroom_ceiling_light
        set_level:
          - service: light.turn_on
            data:
              entity_id: light.bedroom_ceiling_light
              brightness: "{{ brightness }}"
        set_temperature:
          - service: light.turn_on
            data:
              entity_id: light.bedroom_ceiling_light
              color_temp: "{{ color_temp }}"
        set_rgb:
          - service: esphome.bedroom_cmd_ceiling_light_controller
            data:
              cmd: 0x22
              param: "{{ r }}"
              arg0: "{{ g }}"
              arg1: "{{ b }}"
              arg2: 0

I also found commands to enable (0x1E) and disable (0x1F) a very ugly RGB animation, in case anyone wants to hurt their eyes !

I'll leave this issue open because it still exists on this repo :relaxed: