Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Improvements #625

Open
dermotos opened this issue Aug 6, 2024 · 3 comments
Open

Documentation Improvements #625

dermotos opened this issue Aug 6, 2024 · 3 comments

Comments

@dermotos
Copy link

dermotos commented Aug 6, 2024

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?

@ALERTua
Copy link
Contributor

ALERTua commented Aug 6, 2024

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

@SnokxStefan
Copy link

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

@mefranklin6
Copy link

@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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants