Property | Value |
Additional Keywords | Github |
URL | https://github.com/xannor/hass_py_set_state |
Source | internet |
Created | 2023-02-25T03:08:00.000Z |
Already Read | false |
Name | Home Assistant Python Script to set an entity state |
parent | References |
Home Assistant Python Script to force set an entity state
This script adds a service that lets you update the state and/or attributes of any entity, similar to the developer tools
Requires python_script:
to be enabled in you configuration
Requirements:
python_scripts:
in your Home Assistant configurationpython_scripts
as option, in the HACS configuration. (If you missed this, kindly read below!)You are only able to use this custom repo with HACS, if Python Scripts is enabled in Home Assistant. Also, "python_scripts" should have been enabled during the HACS setup through "Integrations" in Home Assistant.
If you missed that part, you need to remove HACS, and add it again, in order to find the "Python Script" category! This time, remember to set a checkmark in "Enable python_scripts discovery & tracking":
Find more information about the HACS configuration here and here. If you used the YAML-way to configure HACS, it's a bit easier. Just edit the YAML configuration for HACS. That parts is also mentioned https://hacs.xyz/docs/categories/python_scripts#enable-if-you-used-yaml-to-configure-hacs.
Copy the Python script in to your /config/python_scripts
directory.
Each call requires at least an entity_id and a state or attributes (otherwise it wont do anything)
example:
entity_id: sensor.random_sensor state: 0 allow_create: true
(Thanks to @rodpayne for the initial script: (https://community.home-assistant.io/t/how-to-manually-set-state-value-of-sensor/43975)
I'm not that used to HACS, but i spotted #1 - so i guess it's better with more details about HACS here.
It would be even better to ask the HACS team to add a disclaimer on the "hacs/settings" page, about missing categories. I guess most users just started using HACS, would like that. But i don't have the time to do that, right now.
Thanks for making the scrip ready for HACS, btw :-)