Instalacja bramki SUPLA-VIRTUAL-DEVICE z obsługą termometrów LYWSD03MMC

User avatar
myxhir
Posts: 664
Joined: Thu Jan 07, 2021 12:16 pm
Location: Skórzewo, Poznań
Has thanked: 6 times
Been thanked: 9 times

Post

U mnie też był problem z czujnikami że się gubił i nie było odczytu, często też miałem problem że jakieś dziwne wartości temp się robiły. Może to przypadek ale u siebie postawiłem monita oraz skrypt który klimas wstawił. Monit działa w tle jako proces a skrypt co chyba 4 min ponad to restartuje sobie svd co 9 min i raz dziennie supervisora i mi tam pomaga xD
Spełniony Automatyk / Mąż / Świeżo Upieczony Ojciec
User avatar
klimasstudio
Posts: 1273
Joined: Wed Aug 28, 2019 9:35 pm
Location: localhost

Post

Potwierdzam u mnie też wiesza się co kilka dni proces i nie zczytuje nic...

Sprawdziłem LOGi a tam cisza 21 i 24 restartowałem ręcznie proces SVD.

Code: Select all

2022-11-17 00:05:31,737 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-17 00:05:31,737 INFO supervisord started with pid 2425854
2022-11-17 00:05:32,743 INFO spawned: 'supla-virtual-device' with pid 2425944
2022-11-17 00:05:33,790 INFO success: supla-virtual-device entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-21 07:28:03,730 INFO waiting for supla-virtual-device to die
2022-11-21 07:28:03,743 INFO stopped: supla-virtual-device (exit status 0)
2022-11-21 07:28:04,793 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If >
2022-11-21 07:28:04,793 INFO Included extra file "/etc/supervisor/conf.d/mi-th0.conf" during parsing
2022-11-21 07:28:04,793 INFO Included extra file "/etc/supervisor/conf.d/supla-virtual-device.conf" during parsing
2022-11-21 07:28:04,821 INFO RPC interface 'supervisor' initialized
2022-11-21 07:28:04,822 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-21 07:28:04,824 INFO supervisord started with pid 3131758
2022-11-21 07:28:05,831 INFO spawned: 'supla-virtual-device' with pid 3131821
2022-11-21 07:28:06,868 INFO success: supla-virtual-device entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-24 22:31:31,246 INFO waiting for supla-virtual-device to die
2022-11-24 22:31:32,317 INFO stopped: supla-virtual-device (exit status 0)
2022-11-24 22:31:33,312 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If >
2022-11-24 22:31:33,315 INFO Included extra file "/etc/supervisor/conf.d/mi-th0.conf" during parsing
2022-11-24 22:31:33,317 INFO Included extra file "/etc/supervisor/conf.d/supla-virtual-device.conf" during parsing
2022-11-24 22:31:33,338 INFO RPC interface 'supervisor' initialized
2022-11-24 22:31:33,339 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-24 22:31:33,340 INFO supervisord started with pid 2371461
2022-11-24 22:31:34,345 INFO spawned: 'supla-virtual-device' with pid 2371510
2022-11-24 22:31:35,368 INFO success: supla-virtual-device entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Dodałem do crona wpis:

Code: Select all

  @daily sudo service supervisor restart
Więc chodź OSUPLUJE Ci dom :mrgreen:

Druk 3D - > https://klimastech.eu.org/druk-3d
User avatar
myxhir
Posts: 664
Joined: Thu Jan 07, 2021 12:16 pm
Location: Skórzewo, Poznań
Has thanked: 6 times
Been thanked: 9 times

Post

klimasstudio wrote: Thu Nov 24, 2022 9:36 pm Potwierdzam u mnie też wiesza się co kilka dni proces i nie zczytuje nic...

Sprawdziłem LOGi a tam cisza 21 i 24 restartowałem ręcznie proces SVD.

Code: Select all

2022-11-17 00:05:31,737 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-17 00:05:31,737 INFO supervisord started with pid 2425854
2022-11-17 00:05:32,743 INFO spawned: 'supla-virtual-device' with pid 2425944
2022-11-17 00:05:33,790 INFO success: supla-virtual-device entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-21 07:28:03,730 INFO waiting for supla-virtual-device to die
2022-11-21 07:28:03,743 INFO stopped: supla-virtual-device (exit status 0)
2022-11-21 07:28:04,793 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If >
2022-11-21 07:28:04,793 INFO Included extra file "/etc/supervisor/conf.d/mi-th0.conf" during parsing
2022-11-21 07:28:04,793 INFO Included extra file "/etc/supervisor/conf.d/supla-virtual-device.conf" during parsing
2022-11-21 07:28:04,821 INFO RPC interface 'supervisor' initialized
2022-11-21 07:28:04,822 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-21 07:28:04,824 INFO supervisord started with pid 3131758
2022-11-21 07:28:05,831 INFO spawned: 'supla-virtual-device' with pid 3131821
2022-11-21 07:28:06,868 INFO success: supla-virtual-device entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-24 22:31:31,246 INFO waiting for supla-virtual-device to die
2022-11-24 22:31:32,317 INFO stopped: supla-virtual-device (exit status 0)
2022-11-24 22:31:33,312 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If >
2022-11-24 22:31:33,315 INFO Included extra file "/etc/supervisor/conf.d/mi-th0.conf" during parsing
2022-11-24 22:31:33,317 INFO Included extra file "/etc/supervisor/conf.d/supla-virtual-device.conf" during parsing
2022-11-24 22:31:33,338 INFO RPC interface 'supervisor' initialized
2022-11-24 22:31:33,339 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-24 22:31:33,340 INFO supervisord started with pid 2371461
2022-11-24 22:31:34,345 INFO spawned: 'supla-virtual-device' with pid 2371510
2022-11-24 22:31:35,368 INFO success: supla-virtual-device entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Dodałem do crona wpis:

Code: Select all

  @daily sudo service supervisor restart
ja u siebie dodalem do Crona takie cos, czyli restartuje svd co 9 min w niczym to nie przeszkadza a czasami mi sie potrafilo zwiesic to prewencyjnie robie to co 9 min czyli nawet jakby w przedziale 10 min uwiesilo sie to w histori bede mial slupek :D dodatkowo restart supervisora + ubicie bluepyhelpera a to wlasnie ten proces u mnie jak sie zawieszal to powodowal uzycie procka na 100% i brak polaczenia z jednym z czujnikow. jak wlasnie nie mialem polaczenia z czujnikiem czyli np odczyty z czapy albo --- to po zalogowaniu sie do maliny i ubiciu procesu od razu mialem temperature i komunikacje - moze to jest klucz. A i te komendy mam nie w zwyklym cronie ale tym odpalanym sudo crontab -e
You do not have the required permissions to view the files attached to this post.
Spełniony Automatyk / Mąż / Świeżo Upieczony Ojciec
User avatar
klimasstudio
Posts: 1273
Joined: Wed Aug 28, 2019 9:35 pm
Location: localhost

Post

A co masz w pliku: bt-chck.sk ?
Więc chodź OSUPLUJE Ci dom :mrgreen:

Druk 3D - > https://klimastech.eu.org/druk-3d
User avatar
myxhir
Posts: 664
Joined: Thu Jan 07, 2021 12:16 pm
Location: Skórzewo, Poznań
Has thanked: 6 times
Been thanked: 9 times

Post

nie wiem czy to nie jest ten sam kod co Ty dawales na swoim blogu ;)

Code: Select all

#!/bin/bash
for PID in $(ps -ef | egrep "(/bin/sh -c /supla-mi-th/LYWSD03MMC.py)|(bluepy-helper)" | grep -v grep | awk {'print$
RUNTIMESEC=$(ps -o etimes= -p "$PID")
if [ "$RUNTIMESEC" -gt "300" ]; then kill -9 $PID; fi
done
exit 0
a w kodzie sprawdzajacym polaczenie mam, czasami musialem resetowac router lub tez router czasami sam mi sie restartuje i potem po ponownym polaczeniu malina sie w ogole nie laczyla co mnie wkurzalo dlatego mam taki skryp znaleziony w necie sprawdzajacy czy jest polaczenie. U mnie sie sprawdza jak resetne router malina sama sie uruchamia ponownie ;)

Code: Select all

#!/usr/bin/env python
#
# networkChecker
#
# Checks whether a server is available to the Raspberry Pi.
# If it's not available, the RasPi is told to restart
# To be run periodically (cron job)
#
# AJH 2014


import argparse
import os
from datetime import datetime
import logging


def check_for_sudo():
	"""Check whether we are dealing with the root user."""
	if os.geteuid() == 0:
		return True
	else:
		return False

def get_current_time():
	d = datetime.now()
	time = {}
	time["timestring_long"] = "{0}-{1:02d}-{2:02d} at {3:02d}:{4:02d}:{5:02d}".format(d.year, d.month, d.day, d.hour, d.minute, d.second)
	time["timestring_short"] = "{:02d}:{:02d}:{:02d}".format(d.hour, d.minute, d.second)
	return time

def setup_logging(logfilename):
	# Set up a log file
	logging.basicConfig(filename=str(logfilename), format='%(levelname)s:%(message)s', level=logging.INFO)
	ct = get_current_time()	
	logging.debug(" networkChecker -- START -- {}".format(ct['timestring_long']))

def ping_the_server(args):
	"""Send a ping to the server"""
	cmd = "ping -q -c {} {}".format(args.n, args.host)
	response = os.system(cmd)
	logging.debug("Sending command: {}".format(cmd))
	return response
	
def main(args):
	"""Check whether server is up"""
	# set up log file
	if not args.logfile:
		setup_logging("{}/networkchecker.log".format(os.getcwd()))
	else:
		setup_logging(args.logfile)
	is_sudo = check_for_sudo()
	if is_sudo:
	    logging.debug("Running as sudo user")
	if not is_sudo:
	    logging.debug("Not running as sudo user")
	# send a ping to the server
	response = ping_the_server(args)
	if response == 0:
		ct = get_current_time()	
		logging.info("{0} is up. ({1})".format(args.host, ct['timestring_long']))
		#everything is fine, don't do anything else
	else:
		logging.info("{0} is not reachable".format(args.host))
		# Restart Raspberry Pi when host is not reachable;
		# this should hopefully make network drive available again
		if is_sudo and args.restart:
			ct = get_current_time()
			logging.info("System shutting down now for restart at {}".format(ct['timestring_long']))
			try:
				os.system("sudo shutdown -r now") # this has to be run as sudo
			except:
				logging.info("Shutdown command unsuccessful.")
		elif args.restart and not is_sudo:
			logging.debug("Not shutting down. Sudo permissions required")
	ct = get_current_time()	
	logging.debug(" networkChecker -- STOP -- {}".format(ct['timestring_long']))

	
if __name__ == '__main__':
	parser = argparse.ArgumentParser(description='Network Checker')
	parser.add_argument('-s', '--server', dest='host', help="Server to ping at regular intervals")
	parser.add_argument('-n', '--number', dest='n', default=10, help="Number of pings to send")
	parser.add_argument('-r', '--restart', dest='restart', help="Restart RasPi if server is down", action="store_true")
	parser.add_argument('-l', '--log', dest='logfile', help="Log file name and path")
	args = parser.parse_args()
	main(args)
Dodam jeszcze że w momencie jak się proces wieszał to widziałem to w malinie po temp, od razu szła do 55 stopni jak widać poniżej od dawna jest spokój jeden pik do 55 na przestrzeni 90 dni czyli to był ostatni moment kiedy coś się działo. Swoją drogą ta temp z maliny okazała się bardzo pomocna :-D
You do not have the required permissions to view the files attached to this post.
Spełniony Automatyk / Mąż / Świeżo Upieczony Ojciec
Jacaxx1
Posts: 87
Joined: Tue Nov 20, 2018 7:33 pm

Post

Koledzy proszę o pomoc, postawiłem bramkę na terminalu wyse Linux mint,po kilku dniach udało mi się w końcu uruchomić bramkę ale teraz mam taki problem że co chwilę zrywa mi połączenie BT z termometrem co chwilę komunikat rozłączono, połączono i tak cały czas,gdzie szukać przyczyny?
User avatar
shimano73
Posts: 2174
Joined: Sun Feb 28, 2016 12:27 pm
Location: Orzesze
Been thanked: 1 time

Post

U mnie inny problem jakiś czas temu postawiłem svd na malinie z 4 czujnikami xiaomi i było ok , niestety malina poszła z dymem. Chciałem to samo ogarnąć na teminalu wyse ale on nie potrafi się połączyć z żadnym czujnikiem ,
system je widzi, bo

Code: Select all

dariusz@Wyse:~/supla-mi-th$ sudo hcitool lescan
LE Scan ...
A4:C1:38:BA:DA:44 LYWSD03MMC
A4:C1:38:3F:9C:2C (unknown)
A4:C1:38:3F:9C:2C LYWSD03MMC
A4:C1:38:6F:70:41 (unknown)
A4:C1:38:6F:70:41 LYWSD03MMC
D0:0D:79:81:7E:B3 (unknown)
A4:C1:38:97:3A:E9 (unknown)
A4:C1:38:97:3A:E9 ATC_973AE9
^C
dariusz@Wyse:~/supla-mi-th$ python3 ./LYWSD03MMC.py  --device A4:C1:38:6F:70:41  --battery --round --debounce --name th0 --callback save-to-file.sh
---------------------------------------------
MiTemperature2 / ATC Thermometer version 5.0
---------------------------------------------


Please read README.md in this folder. Latest version is available at https://github.com/JsBergbau/MiTemperature2#readme
This file explains very detailed about the usage and covers everything you need to know as user.


Trying to connect to A4:C1:38:6F:70:41
Connection lost
Waiting...
Trying to connect to A4:C1:38:6F:70:41
Connection lost
Waiting...
Trying to connect to A4:C1:38:6F:70:41
Connection lost
Waiting...
Trying to connect to A4:C1:38:6F:70:41
Connection lost
Waiting...
Trying to connect to A4:C1:38:6F:70:41
Connection lost
Waiting...
Trying to connect to A4:C1:38:6F:70:41
Connection lost
Waiting...
Trying to connect to A4:C1:38:6F:70:41
Connection lost
^Cdariusz@Wyse:~/supla-mi-th$

Nie znam sie na komunikacji bluetooth , ale czy ,gdy czujnik byl sparowany z maliną to teraz nie łączy sie z terminalem ?
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
User avatar
lesny8
Posts: 3132
Joined: Mon Dec 11, 2017 9:43 pm
Has thanked: 10 times
Been thanked: 9 times

Post

Jak termometr aktualnie nie jest połączony to możesz go połączyć z drugim urządzeniem. Jest to zwykłe połączenie po BT.

Ja ostatnio stawiałem bramkę koledze na RPi ustawiłem crona co 5min, który odpalał skrypt. a w skrypcie połączenie z termometrami, odczyt parametrów i rozłączenie. Więc ikonka raz na 5 min się pojawia na wyświetlaczu termometrów. Ciekawy jestem na ile w tym trybie starczą baterie ;)
To połączenia z Suplą zamiast SVD zainstalowałem SD na linux i ustawiłem kanały na czytanie z pliku. Domyślnie w SD jak w ciągu 10min się plik nie zmieni, to w apce będzie info o niedostępnym kanale.

Dzień później zabrałem się za przenoszenie swoich termometrów z jednego RPi na drugiego, na pierwszym miałem SVD na drugim skompilowałem SD na linux. Poustawiałem jak u kolegi, a potem wszystko wywróciłem do góry nogami :lol:
A to dlatego, że poczytałem i postanowiłem w końcu wykorzystać możliwość odczytu z BLE bez połączenia z termometrami, co równa się z dłuższym działaniem na baterii. Wgrałem alternatywny soft. Teraz skrypt odczytujący pomiary z wszystkich moich kostek, działa w trybie pasywnym :D
Procek nie szaleje, ramu nie brakuje, malina się nie wiesza, git malina :mrgreen:
SOP 2023 :heavy_check_mark:
SOP 2024 :heavy_check_mark:
Czekam na kolejne Supla Offline Party :upside_down_face:
🧩: 🔑cz->b ⛴️+ila
User avatar
shimano73
Posts: 2174
Joined: Sun Feb 28, 2016 12:27 pm
Location: Orzesze
Been thanked: 1 time

Post

lesny8 wrote: Sun Jan 08, 2023 9:02 pm Jak termometr aktualnie nie jest połączony to możesz go połączyć z drugim urządzeniem. Jest to zwykłe połączenie po BT.

Ja ostatnio stawiałem bramkę koledze na RPi ustawiłem crona co 5min, który odpalał skrypt. a w skrypcie połączenie z termometrami, odczyt parametrów i rozłączenie. Więc ikonka raz na 5 min się pojawia na wyświetlaczu termometrów. Ciekawy jestem na ile w tym trybie starczą baterie ;)
To połączenia z Suplą zamiast SVD zainstalowałem SD na linux i ustawiłem kanały na czytanie z pliku. Domyślnie w SD jak w ciągu 10min się plik nie zmieni, to w apce będzie info o niedostępnym kanale.

Dzień później zabrałem się za przenoszenie swoich termometrów z jednego RPi na drugiego, na pierwszym miałem SVD na drugim skompilowałem SD na linux. Poustawiałem jak u kolegi, a potem wszystko wywróciłem do góry nogami :lol:
A to dlatego, że poczytałem i postanowiłem w końcu wykorzystać możliwość odczytu z BLE bez połączenia z termometrami, co równa się z dłuższym działaniem na baterii. Wgrałem alternatywny soft. Teraz skrypt odczytujący pomiary z wszystkich moich kostek, działa w trybie pasywnym :D
Procek nie szaleje, ramu nie brakuje, malina się nie wiesza, git malina :mrgreen:
Tez czytałem o tym połączeniu pasywnym, tworzyłeś plik z lista czujników z "decryption" ?
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
User avatar
lesny8
Posts: 3132
Joined: Mon Dec 11, 2017 9:43 pm
Has thanked: 10 times
Been thanked: 9 times

Post

Nie, nie tworzyłem tego pliku.
Ten plik się tworzy dla zaszyfrowanych kostek, jak nie zmieniasz firmware. Tej opcji nie próbowałem, bo poszedłem na całość i zmieniłem FV :D
SOP 2023 :heavy_check_mark:
SOP 2024 :heavy_check_mark:
Czekam na kolejne Supla Offline Party :upside_down_face:
🧩: 🔑cz->b ⛴️+ila

Return to “Pomoc”