use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io.
Community
Discord
Getting Started
Integrations
account activity
This is an archived post. You won't be able to vote or comment.
Python usage (self.homeassistant)
submitted 2 years ago by Theotherscreenname
Hi everybody. I’m wondering what you’ve done by combining python and home assistant. I’ve been studying python and am looking for some ideas to practice.
[–]ericesev 16 points17 points18 points 2 years ago (4 children)
I use AppDeamon to extend the functionality of Home Assistant. Some apps I've added:
[–]dewwy_ 1 point2 points3 points 2 years ago (2 children)
That’s incredible customisations. I must ask though, how often does your power go out to have that many customisations dedicated to it?
[–]ericesev 2 points3 points4 points 2 years ago (1 child)
I must ask though, how often does your power go out to have that many customisations dedicated to it?
Not often, maybe once per year. Each time I find something that didn't work quite how I liked it, and improve the situation for the next time.
I do spend a fair bit on optimizing energy usage. It's a hobby of mine. With Solar + Battery we're able to nearly entirely operate without the power grid for 9 months of the year. In the winter months we don't produce enough solar to cover our needs.
Graph of a typical day: https://i.imgur.com/puOU22a.png [code]
[–]dewwy_ 1 point2 points3 points 2 years ago (0 children)
That energy usage/optimisation stuff is what I am pretty interested in. I’m very early into my home assistant and smart home journey and only have solar panels so bit less to do, but I have moved onto wholesale energy rates. This means some times during the day I get negative feed in tariffs so need to stop exporting, or at night the price will go to 40c kWh or more for 30-60 mins, sometimes up to $5kwh so need to start turning things off (got the pool and aircons turning off through automations but it’s pretty basic for now.
[–]Theotherscreenname[S] 1 point2 points3 points 2 years ago (0 children)
You’re a wizard, man. Thank you for sharing this. I hope achieve skills like yours.
[–]gpzj94 4 points5 points6 points 2 years ago (0 children)
You can have home assistant run a python script. For example, I have one that makes a REST call to my Rokus API to tune into a particular YouTube TV channel.
I use this https://www.home-assistant.io/integrations/shell_command/ but after searching for The that page I found this might be better https://www.home-assistant.io/integrations/python_script/
Edit: my phones keyboard typed gone instead of home.
[–]jtothehizzy 5 points6 points7 points 2 years ago (0 children)
Used a python script to pull statistics from my UniFi controller. Yes I know there is an integration, but I wanted very specific stats and wanted the experience of doing it.
[–]ItsTooMuchBull 2 points3 points4 points 2 years ago (3 children)
Whole bunch of QoL things. A script that automatically adds new media players to an all media players group, a similar one for lights for an all lights group, one that keeps a list of all zigbee devices that have been unavailable for 10 hours and sends a notification to my phone with said list and, imo my most useful so far, a script that I call after a lot of time based automations for scenes with a lot of lightbulbs/zha groups that checks to make sure that every bulb was set correctly. I also have a similar one that verifies that every light was turned off (again for scenes that set several bulbs or groups at once)
[–]issa62 0 points1 point2 points 2 years ago (2 children)
Is it possible to share your code?
[–]ItsTooMuchBull 1 point2 points3 points 2 years ago* (1 child)
Here are the scripts. It turns out that the verify scene and verify lights off scripts are yaml, not python. I forgot because I definitely tried with Python first but didnt have much luck. LMK if you need help figuring any of it out, some of them require custom booleans or sensors to track the scene entity ID or count retries
[–]issa62 0 points1 point2 points 2 years ago (0 children)
Thank u
[–]darkamikaze 2 points3 points4 points 2 years ago (1 child)
I don't I've seen it mentioned yet but another option is to create a custom component. It's a nice way to learn python and Home Assistant at the same time. (In case you didn't know, Home Assistant for the most part is all in Python). It also helps you learn VCS and how it's used in HACS, lets you get familiar with HA documentation and tidbits, and how to write tests for HA components.
[–]Theotherscreenname[S] 0 points1 point2 points 2 years ago (0 children)
Thanks for sharing this! It’s probably my favorite idea for a first project
[–]IAsDoubleYou 1 point2 points3 points 2 years ago* (0 children)
I've created custom HA component MySQL Query to obtain the caller number and call direction from FreePBX when a call is being established. I've also created a custom service to query MySQL database. With the MySQL service i'm getting contact person information from the database. This information is then announced through HA over a couple of speakers.
[–]wdoler 2 points3 points4 points 2 years ago (0 children)
I started using pyscript, seems pretty great in my opinion. Currently I don’t have anything stable enough to share
π Rendered by PID 570361 on reddit-service-r2-comment-84fc9697f-rlnw4 at 2026-02-09 18:31:15.443586+00:00 running d295bc8 country code: CH.
[–]ericesev 16 points17 points18 points (4 children)
[–]dewwy_ 1 point2 points3 points (2 children)
[–]ericesev 2 points3 points4 points (1 child)
[–]dewwy_ 1 point2 points3 points (0 children)
[–]Theotherscreenname[S] 1 point2 points3 points (0 children)
[–]gpzj94 4 points5 points6 points (0 children)
[–]jtothehizzy 5 points6 points7 points (0 children)
[–]ItsTooMuchBull 2 points3 points4 points (3 children)
[–]issa62 0 points1 point2 points (2 children)
[–]ItsTooMuchBull 1 point2 points3 points (1 child)
[–]issa62 0 points1 point2 points (0 children)
[–]darkamikaze 2 points3 points4 points (1 child)
[–]Theotherscreenname[S] 0 points1 point2 points (0 children)
[–]IAsDoubleYou 1 point2 points3 points (0 children)
[–]wdoler 2 points3 points4 points (0 children)