gvigroux / hon

Support of all Haier, Candy, Hoover appliances integrated in the official hOn mobile app. Direct access to all possible services and parameters
MIT License
118 stars 45 forks source link

Poll light status after calling a service or use optimistic local state #54

Closed Marcocanc closed 1 year ago

Marcocanc commented 1 year ago

I'm currently using this integration with the Haier Wine cooler, primarily to control its light. I have wrapped a template light around the service and sensors, however the status is not immediately updated after changing its state which results in the switch flicking back until the next polling request which makes it reflect the correct state. It would be great if the integration could trigger an extra status query after calling the service or alternatively assume an optimistic temporary state until the next request is done via polling.

This is the template code I'm using:

light:
  - platform: template
    lights:
      wine_cooler_light:
        unique_id: wine_cooler_light
        friendly_name: "Wine Cooler Light"
        value_template: "{{ states('sensor.cooler_light_status') }}"
        turn_on:
          service: hon.turn_on_cooler_lights
          data:
            device: xxxxxxxxxxxxxxxxxx
        turn_off:
          service: hon.turn_off_cooler_lights
          data:
            device: xxxxxxxxxxxxxxxxxx
gvigroux commented 1 year ago

I'm currently rewriting some part of the code to be more generic, I will take this into account

gvigroux commented 1 year ago

Can you please test: https://github.com/gvigroux/hon/tree/Full-rework There are now 2 generic services for lights. I don't have lights so I don't know if it works :)

Marcocanc commented 1 year ago

Awesome, will try to give it a try this evening

gvigroux commented 1 year ago

I've updated the main branch with the code. Tell me if it works

gvigroux commented 1 year ago

I'm closing this issue (should work). Please reopen in case it still exists :)