Answer the question
In order to leave comments, you need to log in
What are the ways in which python scripts interact?
Good afternoon! I decided to rewrite my smart home system (loudly).
The system has both managed and passive devices, before all this interacted in 1 script.
Now I decided to change the architecture of the program, create a script (driver) for each device that other programs would access.
Roughly speaking, for each device, I want to write a script that implements all the possible functions of the device, and I need to get the result of the work of the driver script functions from another script. Connecting the script as a library is not suitable because it is running and constantly running in the background.
Roughly speaking, we have:
Light sensor handler script.
I want to find out the illumination of the type lum = get.lum() from any script or turn on the lamp lamp(true)
lamp handler script.
How to do it?
Answer the question
In order to leave comments, you need to log in
If you need something if you are on a certain page and its item in the menu is highlighted, then this cannot be done with css.
Include JQuery and bootstrap.min.js, everything should work out of the box
Example for Bootstrap 3
You write in scripts:
def your_function():
#Тут то, что делает программа. Ну или один из функционалов.
your_script.your_function()
#Если в самом your_script:
your_function()
At one time I took the HDL
protocol as a basis . It uses broadcast UDP packets on port 6000.
In this case, you can do this. When an event occurs (illuminance changes to a certain level), the sensor sends a command to the lamp to turn on / off. The receiver (lamp) is configured to listen to such a command and respond to it.
Thus, you do not need to constantly interrogate the sensor - the sensor itself turns on the lamp with a command.
There, the protocol provides for feedback - when the lamp is switched, it reports its state in the same broadcast packet. Or you can forcefully send a command to give your state (without switching).
I have done it this way. All incoming data is entered into a MySQL database on the Raspberry PI. If you need the last measured light level or lamp status, then we simply take them from the database, and if fresh data is needed, then we send a request through the main microcontroller and receive the data.
I didn’t quite understand your smart home scheme, does it seem like the computer controls everything? My Raspberry stores databases and a smart home website runs on it. The rest is done on microcontrollers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question