Last active
October 27, 2021 14:39
-
-
Save agapovmax/894d8c53f1a6836c23dde8bc7c41d14a to your computer and use it in GitHub Desktop.
Качество сигнала от LTE-модема
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import config | |
from requests.auth import HTTPBasicAuth | |
# Файл с настройками доступа к серверу и т.п. | |
conf = config.Config('config.cfg') | |
data = '"show interface ' + conf['keenetic_interface'] + '"' | |
params = { | |
'Content-Type': 'application/json' | |
} | |
r = (requests.post(url='https://' + conf['keenetic_server'] + '/rci/parse', headers=params, data=data, auth=HTTPBasicAuth(conf['keenetic_username'], conf['keenetic_password']))).json() | |
# Обновляем значение датчиков: | |
url = 'http://' + conf['domoticz_server'] + ':' + conf['domoticz_port'] + '/json.htm?' | |
headers = { | |
'User-Agent' : 'curl/7.61.0', | |
'Charset' : 'UTF-8' | |
} | |
# Добавляем словарь для обновления сенсоров в Domoticz | |
keen_params = { | |
'address': conf['address'], | |
'rssi': conf['rssi'], | |
'cinr': conf['cinr'], | |
'rsrq': conf['rsrq'], | |
'rsrp': conf['rsrp'], | |
'signal-level': conf['signal-level'] | |
} | |
for key, value in keen_params.items(): | |
params = { | |
'type' : 'command', | |
'param': 'udevice', | |
'idx': value, | |
'nvalue': '0', | |
'svalue' : r[key] | |
} | |
requests.post(url,headers=headers,params=params, auth=HTTPBasicAuth(conf['domoticz_username'], conf['domoticz_password'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment