BlackWarrior

 
<<< Назад

Подключение погодных станций WS1080 к MajorDoMo Linux

Устанавливаем компоненты:
sudo apt install python python-pip python-usb
Ставим PYWWS:
sudo pip install pywws
Это тоже надо:
sudo nano /etc/udev/rules.d/39-weather-station.rules
и впихиваем туда это:
ACTION!="add|change", GOTO="station_end" SUBSYSTEM=="usb", ATTRS{idVendor}=="1941", ATTRS{idProduct}=="8021", GROUP="weather" LABEL="station_end"
На всякий случай — перезагружаем.

Сценарий считывания показаний:

#!/bin/bash
/usr/local/bin/pywws-testweatherstation -d -h 1 | tail -n11 > /var/www/getWeather.log
sed -i "6d" /var/www/getWeather.log

absPress="$(grep abs_pressure /var/www/getWeather.log | cut -c 18-)"
absPress=${absPress::-1}
press="$(echo "$absPress"*0.75 | bc)"
humIn="$(grep hum_in /var/www/getWeather.log | cut -c 12-)"
humIn=${humIn::-1}
humOut="$(grep hum_out /var/www/getWeather.log | cut -c 13-)"
humOut=${humOut::-1}
rain="$(grep rain /var/www/getWeather.log | cut -c 10-)"
rain=${rain::-1}
tempIn="$(grep temp_in /var/www/getWeather.log | cut -c 13-)"
tempIn=${tempIn::-1}
tempOut="$(grep temp_out /var/www/getWeather.log | cut -c 14-)"
tempOut=${tempOut::-1}
windAve="$(grep wind_ave /var/www/getWeather.log | cut -c 14-)"
windAve=${windAve::-1}
windDir="$(grep wind_dir /var/www/getWeather.log | cut -c 14-)"
windDir=${windDir::-1}
windGust="$(grep wind_gust /var/www/getWeather.log | cut -c 15-)"
windGust=${windGust::-1}
updatedTime="$(date +%F", "%T)"

mosquitto_pub -h localhost -t "ws1080/abs_pressure" -m $absPress
mosquitto_pub -h localhost -t "ws1080/pressure" -m "$press"
mosquitto_pub -h localhost -t "ws1080/hum_in" -m $humIn
mosquitto_pub -h localhost -t "ws1080/hum_out" -m $humOut
mosquitto_pub -h localhost -t "ws1080/rain" -m $rain
mosquitto_pub -h localhost -t "ws1080/temp_in" -m $tempIn
mosquitto_pub -h localhost -t "ws1080/temp_out" -m $tempOut
mosquitto_pub -h localhost -t "ws1080/wind_ave" -m $windAve
mosquitto_pub -h localhost -t "ws1080/wind_dir" -m $windDir
mosquitto_pub -h localhost -t "ws1080/wind_gust" -m $windGust
mosquitto_pub -h localhost -t "ws1080/updated_time" -m "$updatedTime"

Ну и в планировщик:

*/5 * * * * /var/www/getWeather.sh

Обсуждение (2) (5)

Смотрите так же:
18.02.2020 Вновь про PING
14.10.2019 Резервное копирование MajorDoMo на Яндекс.Диск
14.10.2019 TORифицируем Алису
11.10.2019 И вновь о прокси
15.09.2019 Учим Mikrotik перезагружать USB-модем
19.04.2019 Узнаем свои интернет-данные

Нижняя Тура, Россия

На форуме: Amarok