TP-Link Dimmer (HS220) Automations

I’ve seen the other threads that predate the updates to pyHS100; I’m hoping that this device is mature enough that a few more people have experience with it.

I’ve got a script that fades the dimmer up over a period of time, defined by an input_number that can be set on the front end:

alarm_bedroom:
  alias: 'Wake Up Bedroom'
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.hs220
        brightness: '3'
    - delay:
        seconds: 1
    - service: light.turn_on
      data_template:
        entity_id: light.hs220
        brightness: 255
        transition: '{{ states.input_number.alarm_duration.state | multiply(60) | int }}'

When I run this script, the light goes on at 100% and immediately dims to its lowest number. One second later, it then immediately transitions to 100% brightness again. For the record, the template currently resolves to ‘300’.

The transition is obviously not working. Can anyone vouch for the transitions actually working for this device?

Any tips on how to avoid the initial “flash” when the light turns on and just have it fade up from minimum?

Thanks.

Order of operations error. You are multiplying a string by 60 and then converting to an integer. You want to convert to an int first then multiply by 60. Like this:

transition: "{{ states('input_number.alarm_duration')|int * 60 }}"

Also note the use of states('domain.object_id') instead of states.domain.object_id.state .This form produces no errors if the state is unknown - as may happen at start up.

Thanks for the correction, but unfortunately I’m still not getting a transition, even using your updated version. The same thing happens - on @ 100%, near-immediate drop to dim, wait one second, and then back to 100%

I have also run into this problem with the TP Link dimmers. It’s as if they get a turn on command a second before they get the rest of the data. Very frustrating and hopefully there’s some workaround that is found.