pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

Documentation Improvements

Open dermotos opened this issue 1 year ago • 3 comments

I'm loving Pyscript for my automations in HA. For any developer, it's the way to write home automations as far as I'm concerned, espicially compared to the HA UI, of the yaml automation approach.

However, I find the documentation very lacking. It really needs some example code. Take the @state_active decorator. From the couple of short paragraphs describing this, I can't really figure out how I use it, or why I would use it over a @state_trigger.

Are there any plans to improve the documentation and add some example code to things like this?

dermotos avatar Aug 06 '24 04:08 dermotos

I made a PR for this #626 Hope you find it useful

ALERTua avatar Aug 06 '24 08:08 ALERTua

Great request, i'm also not an IT expert, so relying on examples.... e.g. how to convert this automation to pyscript ? alias: KuisRobot kuisen bij weg van Huis description: "" triggers:

  • entity_id: device_tracker.smartphone zone: zone.home event: leave trigger: zone conditions: [] actions:
  • device_id: 123 domain: vacuum entity_id: 456 type: clean mode: single

SnokxStefan avatar Oct 18 '24 15:10 SnokxStefan

@SnokxStefan I too learn best from examples and hope to contribute some to the documentation now that I'm understanding how things work. When porting from YAML to Python, you'll have to re-think some approaches as there's not always a way to port 1:1, and of course there's multiple ways to do things. A good foundational knowledge of Python is also very helpful. Happy coding!

@state_trigger("device_tracker.smartphone")
def your_function_name(old_value=None):
    if old_value == "home":  
        vacuum.start(entity_id="456", type="clean", mode="single")

mefranklin6 avatar Oct 22 '24 22:10 mefranklin6