Pyscript: Create a "working" light entity with dimming, possible?

I’m creating a light entity using:

attr_dict = {
    "friendly_name": "Dimmer Test",
    "supported_color_modes": ["brightness"],
    "brightness": 0,
    "icon": "mdi:lightbulb",
}
state.set("light.dimmer_test", "off", attr_dict)

The entity is created and showing up in HA. If i add the entity to a tile card, i can add the feature “Light brightness” so i can change the brightness.

So far so good.

However, if i do any changes to the entity through the user interface i get a warning in the log saying:

Referenced entities light.dimmer_test are missing or not currently available

Can’t figure out whats missing to make the entity change state or update the brightness value, or if its even possible with pyscript to create an entity with the domain “light”?

The state trigger doesn’t get fired either.

@state_trigger("light.dimmer_test == 'on'")
def state_trigger():
    log.info("Trigger ON: light.dimmer_test")

Did you figure this out. lookng at more or less exactly the same problem :slight_smile:

Same here. Has anyone figured out how this is supposed to work correctly?