#control home assistant using python
22 messages · Page 1 of 1 (latest)
That's a very open ended question - how exactly are you trying to control it?
There are at least 4 ways you can “control” HA from Python: the python_script integration, pyscript, AppDaemon, or via REST/Websockets API and external scripts. But, to @sharp wharf’s question. What do you want or need to do?
I think the easyest way is the api
lol it’s not, but whatever works for you works! 😊
basically I wrote a python script and this python script is see if I go into my room and I want to do If the script see me my light is turn on (sorry I can speak a litle bit english because I'm a hungarian)
No worries. Not sure why you need a Python script for that though. You can do that through a simple automation.
what kind of automation?
Basically implement your script as a home assistant automation
It’s a simple motion lighting automation. There’s even a blueprint for that included in HA.
I can implement a python script to HA?
You can, but I meant just remake the functionality
I see
It's not a motion lightning automation. It's a human detector and if the detector see me do something
The concept is the same.
How is it detecting humans?
Most likely it’s a Tuya mmWave sensor. They’re the only ones I know of that use “human presence” as a marketing thing. lol
in the oencv libary have a model and compares
Here is the code:https://github.com/simsononroad/cam_detector/tree/main
(in the code I used hungarian language)
now it works with wled because I can call an api request
Gotcha, fun.
For that I would recommend linking it into home assistant with mqtt https://pypi.org/project/paho-mqtt/
This would allow you to publish "person detected" and "no person detected" directly into a home assistant sensor which you can use to control the lights