How to get dimmer brightness state of Kasa HS220?

I have a TP-Link Kasa HS220 dimmer switch. I would like to have an automation that sets the brightness of a light the same level as the brightness of the dimmer, but that light is not connected to the switch.

In the developer tools / state, I don’t see the brightness attribute for the HS220, but I can see it for some Ikea light bulb.
When changing the brightness from the switch buttons or the Kasa app, Home-Assistant does get the new brightness level, I can see the change in the overview screen. So Home-Assistant is able to pull the new value, I just have to find how to get that value and use it in my automation.

Here the automation script I have so far.

- id: '1601513191327'
  alias: Auto on kitchen hall
  description: ''
  trigger:
  - device_id: 64512813f6ce4ad69313894bb0ffabcb
    domain: light
    entity_id: light.kitchen_dimmer
    platform: device
    type: turned_on
  condition: []
  action:
  - data:
      brightness_pct: '{{ states.light.kitchen_dimmer.attributes.brightness }}'
      entity_id: light.kitchen_hall
    entity_id: light.kitchen_hall
    service: light.turn_on
  mode: single

Was the light on when you tested? The attributes like brightness and color temp for lights are only showing when the light is on.

The light was probably off. I tried the developer tools again while the light is on and I can see the brightness.

I changed the automation to set the brightness and not brightness_pct.

I checked the logs and there is an error when the automation is triggered.

Error executing script. Invalid data for call_service at pos 1: 
expected int for dictionary value @ data['brightness']

Convert it to an int with a pipe like this:

brightness: "{{ state_attr('light.kitchen_dimmer', 'brightness') | int }}"

I’m still getting the same error.
Is there a way to call state_attr('light.kitchen_dimmer', 'brightness') outside the automation to see what value it return?

Yes, go to Developer Tools -> Templates and put the code there.

Are you running a version < 0.115.0? If so, you need to change data: to data_template:

It worked! Thank you.

I find that the switch is slow to turn on/off the lights. I understand that there can be delay due to Home-assistant for the lights that are turned on/off by an automation, but even the lights wired to the switch are slow to respond when using the switch.
I expected the switch to be instantaneous. I have Ikea lights with their remote and the reaction time is faster.

No, there should be no delay from home assistant or only such a small one that it is not perceiveable by the human eye. Sounds for me more like an issue with the TP Link switches, mine always switch instantly.

Ok, I going to try other switches.
Thanks