E
E
Eugene2017-04-15 14:01:09
css
Eugene, 2017-04-15 14:01:09

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

7 answer(s)
N
Nikolay, 2018-04-15
@iNickolay

Add style activeto active elementnav-item

D
Daniil Sukhikh, 2018-04-15
@danchiksux

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.

A
Andrew, 2018-04-16
@AndrewHaze

Include JQuery and bootstrap.min.js, everything should work out of the box
Example for Bootstrap 3

L
Leonid, 2017-04-15
@GoldGoblin

Microservice architecture

T
themedev, 2017-04-15
@thematdev

You write in scripts:

def your_function():
    #Тут то, что делает программа. Ну или один из функционалов.

Save all scripts to the cloud (well, if for users, then send them). And import what you need. And if you need to call the function:
your_script.your_function()
#Если в самом your_script:
your_function()

Well, your problem is solved.

M
mysticmirage, 2017-04-20
@mysticmirage

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).

N
Nikolai, 2017-04-20
@Nick495

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 question

Ask a Question

731 491 924 answers to any question