NicoIIT / esphome-components

Custom BLE ADV based components for ESPHome
MIT License
6 stars 4 forks source link

Not really an issue, most likely a request #6

Open gsdovali opened 2 months ago

gsdovali commented 2 months ago

Can this compotent read the keys pressed on the remote and send the information to home assistant?

gsdovali commented 2 months ago

Already read the discussion on HA form and answered my question

NicoIIT commented 2 months ago

Well in fact, I just finished the beta version 😄 You can beta test this in dev branch:

external_components:
  - source: github://NicoIIT/esphome-components@dev
    refresh: 0s

I let you refer to the global doc (also in beta...), just tell me if it works for you !

gsdovali commented 2 months ago

I've updated to the dev branch and installed the remote, I can't see any change in HA when a button is pressed on the control. Maybe I am missing something this is how I configured. ble_adv_remote:

NicoIIT commented 2 months ago

I cannot help without logs and complete config 😄 To activate the relevant logs, add this to your config:

logger:
  level: DEBUG

ble_adv_handler:
  log_raw: true
  log_command: true
  log_config: true

EDIT: And if your remote is paired to your lamp, you should use the "publishing" instead of "controlling", but it should not be the problem.

EDIT2: you should also add the option "commands_as_toggle: true", as it should be useful for your remote, and it may solve your problem!

gsdovali commented 2 months ago

Ok, I changed to "publishing" and it partially works. Fan works ok but "oscillate button" it does not update the status on HA. Light do not work at all, any change on the control does not update in HA. here is my full yaml code external_components:

ble_adv_controller:

light:

fan:

button:

ble_adv_handler: log_raw: false log_command: false log_config: false

ble_adv_remote:

NicoIIT commented 2 months ago

I added the command for Fan Oscillation from the logs you previously gave in this issue, so it should work now.

Still I cannot do the same for the light as I need those logs to find what is the issue and correct it. Could you please provide the logs when you switch the light ON and OFF with your remote (and with the config given previously to activate the relevant logs).

Thanks!

EDIT: I would also need the logs when the "ALL OFF" button is pressed if it does not work neither for the Fan.

gsdovali commented 2 months ago

Here is the log file and the yaml with my full config. On/Off lights do not work when using the control (I mean does not update in HA) also if I turn off the fan from control, oscillation mode is not saved. ventilador-recamara-principal_logs.txt ventilador-recamara-principal.txt

NicoIIT commented 2 months ago

I added the Light ON/OFF Toggle that was not known, the light should work OK now. This should also enable all other light features as the fact the light was OFF was preventing the other features to be taken into account.

For the Fan oscillation, the problem is your device: your Remote is paired to the device directly, so it controls it directly without going via our components. This means that when you stop the fan using the remote and that you restart it using the remote and that the oscillation status is lost, it is due to the fact your fan is resetting the oscillation status. A way to "fight" against this (stupid) behavior has been implemented using option forced_refresh_on_start: true (which is the default) allowing to re send the oscillation and direction status to the Fan when it starts. Unfortunately for you, this option broke the direction...

From your config I see you are using both forced_refresh_on_start: true and the setting of the direction when the fan is turned on. This is generating contradicting commands and I would advise to either remove the automation on 'turn on' or setup the forced_refresh_on_start: false. Should you need another behavior of our component (and be aware we cannot modify how your device is answering to commands), please specify it in detail in a dedicated issue, or re open the one where we discussed it here for the direction.

gsdovali commented 2 months ago

Yes, I have removed the contradicting commands, set "forced_refreshed_on_start: false" and enabled my automation as having the value as true and removing my automation didn't worked. I am still testing if it works as it should. Do you think you can enable the timer option in the control to turn off (light and fan) when pressing 2H and 4H buttons? Last log file I sent you has both key press in the log.

NicoIIT commented 1 month ago

I added the Timer feature, but this feature is fully handled by the controlled device once setup, so you will have to configure when your controlled device is cancelling it, and there is no magic way to understand when your device do it: you will have to test this on your own as for example:

Another test:

And same tests to be done with the Fan, or when changing the light color or brightness...

I also added bunches of Actions to be used, in particular the fan.publish_state that allows to setup the direction or oscillating state in HA without sending a command to the device, and then re align what your device is doing when fan is turned off:

fan:
  - platform: ble_adv_controller
      ble_adv_controller_id: my_controller
      id: my_fan
      name: My Fan
      on_turn_off:
        then:
          ble_adv_controller.fan.publish_state:
            id: my_fan
            direction: forward
            oscillating: false

EDIT: I added the option cancel_timer_on_any_change that is setup to True by default in order to setup a default behavior that may be the one of your device.

gsdovali commented 1 month ago

Sorry it took me longer to reply but I was able to try your updates... I just installed today and. I did modify the button part and configured the remote part... I will test the remotes and get back to you... With the yaml file attached, my fans always start on forward direction, otherwise fans toggle direction on every turn on. I tried all the combos (default forced_refresh_on_start:true. forced_refresh_on_start:false, on_turn_on options changed too) the one set in the current file is the only one that worked. I've also notices on @dev branch OTA file is getting updated successfully over wifi, older versions it failed.

I will test timer function and report back ventilador-recamara-principal.txt

NicoIIT commented 1 month ago

Well the goal is not to have all options working for everyone, but to have everyone having at least one of those options working!

Have you tried the "on_turn_off" option I gave? From what you described I would have think this was the option you needed.

For the OTA issue, I do not see how the dev branch would be better than the main, as the OTA is part of the common ESPHome framework and has nothing to do (a priori) with the software of ble_adv components. I would bet this is more a bit of luck or not if it works. Personally I find the ESPHome OTA update very unstable, I always use USB. 😃