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

Does this still work even with the 2022.3 update of HA? #4

Open
ThePrincelle opened this issue Mar 13, 2022 · 3 comments
Open

Does this still work even with the 2022.3 update of HA? #4

ThePrincelle opened this issue Mar 13, 2022 · 3 comments
Assignees

Comments

@ThePrincelle
Copy link
Contributor

Hi,

After seeing an issue (custom-components/pyscript#331) in the pyscript project, I was wondering if there may be a similar problem with this component too.

Thanks for your response,
Maxime

@dlashua
Copy link
Owner

dlashua commented Mar 14, 2022

You are absolutely right. This is likely broken against version 2022.3 and later.

I don't actually use this custom component any longer, so a it'll be a bit before I can get around to setting up an environment to test the fix. However, as I sent the PR for the pyscript fix, I'm pretty sure the fix in this case is the same.

I'll happily accept a PR from anyone able to do so. Otherwise, I'll try to get to this later this week.

@dlashua dlashua self-assigned this Mar 14, 2022
@ThePrincelle
Copy link
Contributor Author

ThePrincelle commented Mar 14, 2022

Thanks for your response.
In fact, I'm already using this component with pyscript.

Maybe you can help me use the method provided by pyscript to set an entity and persist it.

# Set State (persist)
def set_state(entity_id=None, value=None, friendly_name=None, icon=None, unit_of_measurement=None, new_attributes=None):
    options = { "friendly_name": friendly_name }

    if icon is not None:
        options['icon'] = icon 
    
    if unit_of_measurement is not None:
        options['unit_of_measurement'] = unit_of_measurement

    if new_attributes is not None:
        for key in new_attributes:
            options[key] = new_attributes[key]

    setter.set(entity_id=entity_id, state=str(value), attributes=options)

I can try to create a PR for this project too, but unfortunately I'm pretty busy at the moment.

@dlashua
Copy link
Owner

dlashua commented Mar 14, 2022

pyscript is unable to persist entities outside of the "pyscript." domain. It isn't that Home Assistant doesn't allow it, but the pyscript code specifically checks for and refuses to persist any entity that isn't "pyscript.*".

If you need persistence (i.e. restoring of state), then hass-setter, as you are using it, is one way to get that. If your pyscript code is capable of recalculating state at startup without the need for persistence, you can just use "state.set(entity_id, value)".

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

2 participants