betaboon / philips-airpurifier-coap

💨 Philips AirPurifier custom component for Home Assistant. With support for new Devices with CoAP protocol. Tested on AC2729/10 (bought early 2020)
70 stars 31 forks source link

Light controls #35

Closed ToeiRei closed 3 years ago

ToeiRei commented 3 years ago

Can you please add a way to change the display brightness as it would make my life a bit easier when I'm able to automatically dim the display at night.

kongo09 commented 3 years ago

This does exist already. Here is my script that I use to do this for my devices:

alias: Toggle AC light
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ is_state(entity_id, "on") }}'
        sequence:
          - choose:
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ not is_state_attr(entity_id, "display_backlight",
                      false) }}
                sequence:
                  - service: philips_airpurifier.set_display_backlight_off
                    data:
                      entity_id: '{{ entity_id }}'
                  - service: philips_airpurifier.set_light_brightness
                    data:
                      entity_id: '{{ entity_id }}'
                      brightness: 0
            default:
              - service: philips_airpurifier.set_display_backlight_on
                data:
                  entity_id: '{{ entity_id }}'
              - service: philips_airpurifier.set_light_brightness
                data:
                  entity_id: '{{ entity_id }}'
                  brightness: 100
mode: single
icon: 'pap:light_dimming_button'
fields:
  entity_id:
    description: Entity of fan
    example: fan.air_ac2729
description: Toggle the backlight of philips AC
ToeiRei commented 3 years ago

Thanks a ton. I was looking at service calls but couldn't find anything useful.

kongo09 commented 3 years ago

Well, there are service calls, three to be precise:

service: philips_airpurifier.set_light_brightness
service: philips_airpurifier.set_display_backlight_off
service: philips_airpurifier.set_display_backlight_on

I just packaged it into a script for myself to have it handy for more than one device and also use it from the interface and from automations more easily.

ToeiRei commented 3 years ago

Thanks! I guess I was just blind. Works like a charm if you do it right (tm)

kongo09 commented 3 years ago

I have added PR #36 to make the available services more obvious.

ToeiRei commented 3 years ago

I was poking around on fan.philips_airpurifier instead of philips_airpurifier