How to correctly create a virtual light entity? (Getting `WARNING (MainThread) [homeassistant.helpers.service] Referenced entities light.virtual_dimmer are missing or not currently available`)
I'm trying to create a virtual light entity by setting its state in my PyScript.
@state_trigger("light.virtual_dimmer == 'on'")
def test():
print("HELLO WORLD!")
attr_dict = {
"friendly_name": "Virtual dimmer",
"supported_color_modes": ["brightness"],
"brightness": 0,
"icon": "mdi:lightbulb",
"device_class": "light",
}
state.set("light.virtual_dimmer", "off", attr_dict)
The entity is created, I can see it in the developer tools. However, when I add it to my dashboard and try to swich it off/on (hoping to see "HELLO WORLD" in the logs) instead I'm getting the WARNING (MainThread) [homeassistant.helpers.service] Referenced entities light.virtual_dimmer are missing or not currently available.
What am I doing wrong? How is this supposed to work correctly? Is this possible at all?
Metadata: Home Assistant: 2025.1 HAOS: 14.1 PyScript: 1.6.1
Hi , I have a similar trouble with all input_select,input_boolean and input_number created inside a pyscript module:
RADIATEURS_MODE_ALL = ["ARRET","LOCAL","VAC"]
attributes= { "options" : RADIATEURS_MODE_ALL,
"editable": "false" ,
"friendly_name": "Radiateurs_all"}
state.set("input_select.radiateurs_all",value="ARRET",new_attributes=attributes)
Impossible to change their value through my dashboad with entity card , with this warning :
Enregistreur: homeassistant.helpers.service
Source: helpers/service.py:304
S'est produit pour la première fois: 10:13:45 (1 occurrences)
Dernier enregistrement: 10:13:45
Referenced entities input_select.radiateurs_all are missing or not currently available
However this entity exist :