pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

service.call() is not generated in pyscript_builtins.py

Open ryan-fessler opened this issue 3 weeks ago • 2 comments

The function service.call() is not generated in pyscript_builtins.py.

This likely conflicts with the @service decorator, so I'm not sure how it would be handled.

There are some cases where I need to use service.call() instead of calling the service directly with domain.name(). For instance, I can't call light.turn_on() with transition set to a float because it expects an int, so I need to use service.call() instead.

ryan-fessler avatar Dec 10 '25 20:12 ryan-fessler

@dmamelin your part of the code :) thank you <3

ALERTua avatar Dec 11 '25 08:12 ALERTua

You’re right, service.call() isn’t included in pyscript_builtins.py due to a conflict with @service.

For instance, I can't call light.turn_on() with transition set to a float because it expects an int

selector:
  number:
    min: 0
    max: 300
    unit_of_measurement: seconds

transition in light.turn_on() is documented as an int. The UI also treats it as an integer and throws an error if you try to enter a non-integer value. But in reality, you can pass a float — the service will accept and process it correctly.

dmamelin avatar Dec 11 '25 10:12 dmamelin

@dmamelin That's understandable about the conflict with @service. I will just specify service.call() as a builtin through Ruff.

For light.turn_on(), transition is definitely documented as an int in seconds — no argument there. That being said, I can pass a float to it (e.g., 0.2) and it will work correctly with my Philips Hue lights connected through zigbee2mqtt. I don't think there's anything that needs to be fixed there. I was just highlighting why I'm using service.call() instead of light.turn_on().

ryan-fessler avatar Dec 11 '25 16:12 ryan-fessler