Witam,
czy ktoś ma może zintegrowany odczyt danych z kotła CO opartego na sterowniku Tech st-480 i modułu Tech st-505?
Temat ruszony na elektrodzie ( https://www.elektroda.pl/rtvforum/topic2689981.html) może jest ktoś kto wytłumaczy jak to zrobić dla OH3?
Cześć.
Jedną z ostatnich wiadomoaci na elektrodzie jest moja wypowiedź. Niestety nikt się nie odezwał. Aktualnie już nie używam sterownika TECH ale "obszedłem" te odczyty ze sterownika Techa. Na bazie ESP 8266 z Tasmotą oraz kilkoma czujnikami temperatury zrobiłem dodatkowy układ za pomocą którego niezależnie monitoruje piec. Dodatkowo dołożyłem czujnik odległości do zasobnika i dzięki temu mam pomiar napełnienia zasobnika.
Witam, Mam sterownik tech i2, czy ktoś umie zrobić połączenie z domoticzem, albo przez esp8266 albo Ethernet. Pozdrawiam. P.s. na elektrodzie użytkownikowi Fantom się udało, ale nie ma z nim kontaktu.
Czyli na tym forum tego nie ruszymy 😶
Znalazłem podobny temat u Supli może komuś coś przyjdzie do głowy...
https://forum.supla.org/viewtopic.php?t=9603
Co myślicie o czymś takim?
import requests import json # Dane dostępowe do konta emodul.pl username = "your_username" password = "your_password" # Zaloguj się do konta emodul.pl login_url = "https://emodul.pl/api/login" login_data = {"username": username, "password": password} login_response = requests.post(login_url, json=login_data) login_response_json = json.loads(login_response.text) # Pobierz token dostępu access_token = login_response_json["access_token"] # Pobierz dane z emodul.pl data_url = "https://emodul.pl/api/data" headers = {"Authorization": "Bearer " + access_token} data_response = requests.get(data_url, headers=headers) data = json.loads(data_response.text) # Publikuj dane w openHAB3 openhab_url = "http://your_openhab_ip:8080/rest/items/your_item_name" for key, value in data.items(): requests.post(openhab_url, json={"state": value})
lub może tak?
rule "Emodul data" when Time cron "0 0/5 * * * ?" // co 5 minut then // Dane dostępowe do konta emodul.pl var String username = "your_username" var String password = "your_password" var String access_token var String data // Zaloguj się do konta emodul.pl var String login_url = "https://emodul.pl/api/login" var String login_data = '{"username":"'+username+'","password":"'+password+'"}' var HttpResponse login_response = sendHttpPostRequest(login_url, "application/json", login_data) if (login_response.responseCode != 200) { logError("Error while logging in to emodul.pl. Response code: " + login_response.responseCode) } else { // Pobierz token dostępu access_token = login_response.headers.get("access_token") // Pobierz dane z emodul.pl var String data_url = "https://emodul.pl/api/data" var HttpResponse data_response = sendHttpGetRequest(data_url, "application/json", null, [new HttpHeader("Authorization", "Bearer " + access_token)]) if (data_response.responseCode != 200) { logError("Error while fetching data from emodul.pl. Response code: " + data_response.responseCode) } else { data = data_response.response // Publikuj dane w openHAB3 parseJson(data).getMembers().forEach[key, value | val String itemName = key val item = getItem(itemName) if (item != null) { postUpdate(itemName, value) } else { logError("Item "+itemName+" not found.") } ] } } end
Bardzo ładnie, ale:
- na elektrodzie skupili sie na rozkminieniu protokołu idącego magistralą szeregową, powyższy kod ściaga dane z chury producenta
- w powyższym kodzie dostajemy dane (w jsonie), które sa rozszyte na poszczególne itemy (ale nazwy itemów musza się pokrywać z nazwami kluczy json).
- w kodzie widzę tylko odczyt danych, tylko to jest potrzebne?
Pozdrawiam
Wolałbym bez chmury ale nie wiem jak 🫤 więc szukam innego sposobu.
Idąc tropem z Suppli loguje się na emodul.pl i po zalogowaniu w adresie dopisuje module _data https://emodul.pl/module_data i wyświetla mi json'a z nazwami, id, i wartościami tego co mam wyświetlane na stronie głównej więc myślę jak to zautomatyzować i wyświetlić w OH
fragment tego co mam z module_data
{"zones":{},"tiles":[{"id":2000,"parentId":0,"type":50,"menuId":0,"orderId":null,"visibility":true, "params":{"description":"Wersja oprogramowania kontrolera","wersja":"1.3.0","txtId":873,"iconId":50,"companyId":30,"controllerName":"ST- 480","mainControllerId":169709}},{"id":2011,"parentId":0,"type":40,"menuId":0,"orderId":2,"visibility":true,"parametry ":{"description":"Informacje tekstowe","statusId":1067,"headerId":1039,"iconId":50,"options":[]}},{"id":2050,"parentId": 0,"type":6,"menuId":2060,"orderId":5,"visibility":true,"params":{"description":"Uniwersalny status z widżetami","statusId":1,"iconId":106,"widget1":{"txtId":760, "value":0,"unit":6,"type":0,"params":[0,0,0,0,0]},"widget2":{"txtId":774,"value": 286,"unit":7,"type":9,"params":[0,0,0,0,0]}}},{"id":2051,"parentId":0,"type": 6,"menuId":2061,"orderId":8,"visibility":true,"params":{"description":"Uniwersalny status z widżetami","statusId":1,"iconId":105,"widget1 ":{"txtId":760,"value":0,"unit":6,"type":0,"parametry":[0,0,0,0,0]},"widget2":{"txtId":1041,"value":782,"unit":7,"type":9,"params":[0,0,0,0,0]}}},{"id ":2053,"parentId":0,"type":1,"menuId":0,"orderId":3,"visibility":true,"params":{"description":"Czujnik temperatury","WorkStatus" ":true,"txtId":795,"value":17,"batteryLevel":null,"signalStrength":null}},{"id":2054,"parentId":0,"type":1," menuId":0,"orderId":4,"visibility":true,"params":{"description":"Czujnik temperatury","workingStatus":true,"txtId":1043,"value":197," poziom baterii":null,"Siła sygnału":null}},{"id":2055,"parentId":0,"type":1,"menuId":0,"orderId":12,"visibility":false,"params":{"description":"Czujnik temperatury","workingStatus":false," txtId":196,"value":-2030,"batteryLevel":null,"signalStrength":null}},{"id":2056,"parentId":0,"type":1,"menuId":0 ","orderId":9,"visibility":true,"params":{"description":"Czujnik temperatury","workingStatus":true,"txtId":1040,"value":229,"batteryLevel":null ","signalStrength":null}},{"id":4050,"parentId":0,"type":21,"menuId":0,"orderId":15,"visibility":false,"params": {"opis":"Dodatkowa pompa","workingStatus":false,"pumpNumber":1,"txtId":922}},{"id":4051,"parentId":0,"type":21,"menuId":0, "orderId":17,"visibility":false,"params":{"description":"Dodatkowa pompa","workingStatus":false,"pumpNumber":2,"txtId":922}},{"id" :4052,"parentId":0,"type":40,"menuId":2006,"orderId":18,"visibility":false,"params":{"description":"Informacje tekstowe","statusId" :473,"headerId":814,"iconId":3,"opcje":[]}},{"id":4056,"parentId":0,"type":11,"menuId":0," orderId":10,"visibility":true,"params":{"description":"Przekaźnik","workingStatus":false,"txtId":571,"iconId":17}},{"id":4057,"parentId":0,"type":11 ","menuId":0,"orderId":14,"visibility":false,"params":
Spójrz na wątek o Airly - @Adrian opisał dokładnie jak dodać takie dane do OH. Tutaj może być problem z zalogowaniem się do chmury ale warto sprawdzić. Potrzebny będzie Http binding i Json. Reszta to stworzenie odpowiednich items (number/test).
@szpila86 JSON musi być kompletny, żeby go sparsować. Wrzuć całą odpowiedź serwera tutaj i kliknij process.
Jak nie będzie błędów wklej tutaj jako kod. Wtedy będzie można JSONPath'em wydobyć parametry.
Można by jeszcze "podsłuchiwać" transmisję sterownika ze stroną na jakimś sprytnym routerze i odczytywać przesyłane parametry (też jest to w tym wątku na elektrodzie), ale to trzeba by napisac coś więcej niż rule do openHABa.
nie zmieniałem nic z ustawień strony.
{ "zones":{ }, "tiles":[ { "id":2000, "parentId":0, "type":50, "menuId":0, "orderId":null, "visibility":true, "params":{ "description":"Controller software version", "version":"1.3.0", "txtId":873, "iconId":50, "companyId":30, "controllerName":"ST-480", "mainControllerId":169709 } }, { "id":2011, "parentId":0, "type":40, "menuId":0, "orderId":2, "visibility":true, "params":{ "description":"Text information", "statusId":1067, "headerId":1039, "iconId":50, "options":[ ] } }, { "id":2050, "parentId":0, "type":6, "menuId":2060, "orderId":5, "visibility":true, "params":{ "description":"Universal status with widgets", "statusId":1, "iconId":106, "widget1":{ "txtId":760, "value":0, "unit":6, "type":0, "params":[ 0, 0, 0, 0, 0 ] }, "widget2":{ "txtId":774, "value":331, "unit":7, "type":9, "params":[ 0, 0, 0, 0, 0 ] } } }, { "id":2051, "parentId":0, "type":6, "menuId":2061, "orderId":8, "visibility":true, "params":{ "description":"Universal status with widgets", "statusId":1, "iconId":105, "widget1":{ "txtId":760, "value":0, "unit":6, "type":0, "params":[ 0, 0, 0, 0, 0 ] }, "widget2":{ "txtId":1041, "value":288, "unit":7, "type":9, "params":[ 0, 0, 0, 0, 0 ] } } }, { "id":2053, "parentId":0, "type":1, "menuId":0, "orderId":3, "visibility":true, "params":{ "description":"Temperature sensor", "workingStatus":true, "txtId":795, "value":6, "batteryLevel":null, "signalStrength":null } }, { "id":2054, "parentId":0, "type":1, "menuId":0, "orderId":4, "visibility":true, "params":{ "description":"Temperature sensor", "workingStatus":true, "txtId":1043, "value":182, "batteryLevel":null, "signalStrength":null } }, { "id":2055, "parentId":0, "type":1, "menuId":0, "orderId":12, "visibility":false, "params":{ "description":"Temperature sensor", "workingStatus":false, "txtId":196, "value":-2030, "batteryLevel":null, "signalStrength":null } }, { "id":2056, "parentId":0, "type":1, "menuId":0, "orderId":9, "visibility":true, "params":{ "description":"Temperature sensor", "workingStatus":true, "txtId":1040, "value":228, "batteryLevel":null, "signalStrength":null } }, { "id":4050, "parentId":0, "type":21, "menuId":0, "orderId":15, "visibility":false, "params":{ "description":"Additional pump", "workingStatus":false, "pumpNumber":1, "txtId":922 } }, { "id":4051, "parentId":0, "type":21, "menuId":0, "orderId":17, "visibility":false, "params":{ "description":"Additional pump", "workingStatus":false, "pumpNumber":2, "txtId":922 } }, { "id":4052, "parentId":0, "type":40, "menuId":2006, "orderId":18, "visibility":false, "params":{ "description":"Text information", "statusId":473, "headerId":814, "iconId":3, "options":[ ] } }, { "id":4056, "parentId":0, "type":11, "menuId":0, "orderId":10, "visibility":true, "params":{ "description":"Relay", "workingStatus":false, "txtId":571, "iconId":17 } }, { "id":4057, "parentId":0, "type":11, "menuId":0, "orderId":14, "visibility":false, "params":{ "description":"Relay", "workingStatus":false, "txtId":573, "iconId":17 } }, { "id":4059, "parentId":0, "type":32, "menuId":0, "orderId":16, "visibility":false, "params":{ "description":"Disinfection", "txtId":922, "percentage":0 } }, { "id":4060, "parentId":0, "type":31, "menuId":0, "orderId":1, "visibility":true, "params":{ "description":"Fuel supply", "percentage":0, "hours":0 } }, { "id":4061, "parentId":0, "type":22, "menuId":0, "orderId":13, "visibility":true, "params":{ "description":"Fan", "workingStatus":false, "fanNumber":0, "gear":0, "txtId":null } }, { "id":4062, "parentId":0, "type":23, "menuId":2220, "orderId":6, "visibility":true, "params":{ "description":"Built-in valve", "workingStatus":true, "valveNumber":0, "currentTemp":240, "returnTemp":230, "setTempCorrection":0, "openingPercentage":15, "valvePump":0, "boilerProtection":0, "returnProtection":1, "setTemp":42, "txtId":-1 } }, { "id":4063, "parentId":0, "type":24, "menuId":2270, "orderId":7, "visibility":true, "params":{ "description":"Built-in valve", "workingStatus":true, "valveNumber":1, "currentTemp":240, "returnTemp":230, "setTempCorrection":0, "openingPercentage":100, "valvePump":0, "boilerProtection":0, "returnProtection":0, "setTemp":38, "txtId":-1 } }, { "id":4065, "parentId":0, "type":11, "menuId":0, "orderId":11, "visibility":true, "params":{ "description":"Relay", "workingStatus":false, "txtId":550, "iconId":101 } } ], "lastUpdate":"2023-01-19 15:05:00.845762+01" }
I wszystko pięknie widać. Teraz wrzucasz tego jsona do lewego pola tekstowego:
U góry podajesz np ponizszy JSONPath i otrzymujesz % otwarcia wewnętrznego zaworu:
$.tiles[?(@.id=='4062')].params.openingPercentage
No i teraz nasz skrypt wygląda tak:
rule "Emodul data" when Time cron "0 0/5 * * * ?" // co 5 minut then // Dane dostępowe do konta emodul.pl var String username = "your_username" var String password = "your_password" var String access_token var String data // Zaloguj się do konta emodul.pl var String login_url = "https://emodul.pl/api/login" var String login_data = '{"username":"'+username+'","password":"'+password+'"}' var HttpResponse login_response = sendHttpPostRequest(login_url, "application/json", login_data) if (login_response.responseCode != 200) { logError("Error while logging in to emodul.pl. Response code: " + login_response.responseCode) } else { // Pobierz token dostępu access_token = login_response.headers.get("access_token") // Pobierz dane z emodul.pl var String data_url = "https://emodul.pl/api/data" var HttpResponse data_response = sendHttpGetRequest(data_url, "application/json", null, [new HttpHeader("Authorization", "Bearer " + access_token)]) if (data_response.responseCode != 200) { logError("Error while fetching data from emodul.pl. Response code: " + data_response.responseCode) } else { data = data_response.response // Publikuj dane w openHAB3 ProcOtwZawItem.postUpdate(transform("JSONPATH", "$.tiles[?(@.id=='4062')].params.openingPercentage", data)) //Następne itemy } } end
Proponuję każdy JSONPath przetestować na stronie przed wrzuceniem do rule.
A ja się na piechotę męczyłem z JSONem 😭
Mimo instalacji Http nie rozpoznaje mi poleceń
Script execution of rule with UID 'eModul-1' failed: 'responseCode' is not a member of 'HttpResponse'; line 15, column 9, length 27 in eModul
może tak to powinno być?
Integer responseCode = request.getResponseCode(); if (responseCode != 200) { httpResponse = responseCode.toString(); }
A dołożyłeś
import requests import json
na początku pliku rules?
tak mam wpisane przed "rules"
nawet stronę z emodul.eu zmieniłem na emodul.pl bo obie niby wyświetlają to samo.
Strone logowania też zmieniłem na
@szpila86 Skąd wziąłęs ten skrypt? Teraz widze, że tam jest błąd: sendHttpPostRequest zwraca tylko String z odpowiedzią serwera, nie zwraca żadnego obiektu, który miałby właściwość responseCode, więc ten if nie ma co sprawdzić ( https://www.openhab.org/docs/configuration/actions.html#http-actions ).
Trzeba to przerobić, żeby skrypt szedł dalej, jeśli odpowiedź serwera nas zadowala.
Cześć
Wymodziłem taki rule. Nieststy nie posiadam zarejestrowanego żadnego modułu, więc mam odpowiedzw postaci pustej tablicy. Endpoint, który podałeś ( https://emodul.pl/api/data) zawsze zwraca 404 Not Found.
Wg mnie należy znaleźć id modulu z odpowiedzi Data response i udczytać dane z endpointa
GET https://emodul.eu/api/v1/users/{user_id}/modules/{module_udid}
rule:
rule "Emodul data" when Time cron "0 0/1 * * * ?" // co 5 minut then // Dane dostępowe do konta emodul.pl var String username = "username" var String password = "pass" var String access_token //var String data var String user_id // Zaloguj się do konta emodul.pl var String login_url = "https://emodul.eu/api/v1/authentication" var String login_data = '{"username": "' + username + '" ,"password": "' + password + '"}' var String login_response = sendHttpPostRequest(login_url, "application/json", login_data) logInfo("Emodul", "Response: {}", login_response) if (login_response === null) { logWarn("Emodul","Empty HTTP response!") return; } access_token = transform("JSONPATH", "$.token", login_response) logInfo("Emodul","Access token: {}", access_token) user_id = transform("JSONPATH", "$.user_id", login_response) logInfo("Emodul","User ID: {}", user_id) // Pobierz dane z emodul.pl GET https://emodul.eu/api/v1/users/{user_id}/modules var String data_url = "https://emodul.eu/api/v1/users/" + user_id + "/modules" //var String data_url = "https://emodul.pl/api/data" var String data_response = sendHttpGetRequest(data_url, newHashMap("Authorization" -> "Bearer " + access_token), 5000) logInfo("Emodul","Data response: {}", data_response) end
Hej
teraz widać że coś się dzieje 😀
reguła się loguje i uzyskuje token tyle widzę na szybko.
Wieczorem połączę się z domem i spróbuję przeanalizować co się dzieje i gdzie się zatrzymuje.
próbuję podejrzeć np
Bardzo roztropnie zrobiłeś, że token nie znalazł się na forum 🙂
Przyznam sie, że użyłem go do przetestowania dalszej części skryptu (nie zrobiłem nic poza odczytem danych) i oto uzyskany w OH wynik:
{ "zones":{ "transaction_time":null, "elements":[ ], "globalSchedules":{ "time":null, "duringChange":null, "elements":[ ] }, "controllerParameters":null }, "tiles":[ { "id":2000, "parentId":0, "type":50, "menuId":0, "orderId":null, "visibility":true, "params":{ "description":"Controller software version", "version":"1.3.0", "txtId":873, "iconId":50, "companyId":30, "controllerName":"ST-480", "mainControllerId":169709 } }, { "id":2011, "parentId":0, "type":40, "menuId":0, "orderId":2, "visibility":true, "params":{ "description":"Text information", "statusId":563, "headerId":1039, "iconId":50, "options":[ ] } }, { "id":2050, "parentId":0, "type":6, "menuId":2060, "orderId":5, "visibility":true, "params":{ "description":"Universal status with widgets", "statusId":1, "iconId":106, "widget1":{ "txtId":760, "value":0, "unit":6, "type":0, "params":[ 0, 0, 0, 0, 0 ] }, "widget2":{ "txtId":774, "value":508, "unit":7, "type":9, "params":[ 0, 0, 0, 0, 0 ] } } }, { "id":2051, "parentId":0, "type":6, "menuId":2061, "orderId":8, "visibility":true, "params":{ "description":"Universal status with widgets", "statusId":1, "iconId":105, "widget1":{ "txtId":760, "value":0, "unit":6, "type":0, "params":[ 0, 0, 0, 0, 0 ] }, "widget2":{ "txtId":1041, "value":614, "unit":7, "type":9, "params":[ 0, 0, 0, 0, 0 ] } } }, { "id":2053, "parentId":0, "type":1, "menuId":0, "orderId":3, "visibility":true, "params":{ "description":"Temperature sensor", "workingStatus":true, "txtId":795, "value":12, "batteryLevel":null, "signalStrength":null } }, { "id":2054, "parentId":0, "type":1, "menuId":0, "orderId":4, "visibility":true, "params":{ "description":"Temperature sensor", "workingStatus":true, "txtId":1043, "value":200, "batteryLevel":null, "signalStrength":null } }, { "id":2055, "parentId":0, "type":1, "menuId":0, "orderId":12, "visibility":false, "params":{ "description":"Temperature sensor", "workingStatus":false, "txtId":196, "value":-2030, "batteryLevel":null, "signalStrength":null } }, { "id":2056, "parentId":0, "type":1, "menuId":0, "orderId":9, "visibility":true, "params":{ "description":"Temperature sensor", "workingStatus":true, "txtId":1040, "value":375, "batteryLevel":null, "signalStrength":null } }, { "id":4050, "parentId":0, "type":21, "menuId":0, "orderId":15, "visibility":false, "params":{ "description":"Additional pump", "workingStatus":false, "pumpNumber":1, "txtId":922 } }, { "id":4051, "parentId":0, "type":21, "menuId":0, "orderId":17, "visibility":false, "params":{ "description":"Additional pump", "workingStatus":false, "pumpNumber":2, "txtId":922 } }, { "id":4052, "parentId":0, "type":40, "menuId":2006, "orderId":18, "visibility":false, "params":{ "description":"Text information", "statusId":473, "headerId":814, "iconId":3, "options":[ ] } }, { "id":4056, "parentId":0, "type":11, "menuId":0, "orderId":10, "visibility":true, "params":{ "description":"Relay", "workingStatus":true, "txtId":571, "iconId":17 } }, { "id":4057, "parentId":0, "type":11, "menuId":0, "orderId":14, "visibility":false, "params":{ "description":"Relay", "workingStatus":false, "txtId":573, "iconId":17 } }, { "id":4059, "parentId":0, "type":32, "menuId":0, "orderId":16, "visibility":false, "params":{ "description":"Disinfection", "txtId":922, "percentage":0 } }, { "id":4060, "parentId":0, "type":31, "menuId":0, "orderId":1, "visibility":true, "params":{ "description":"Fuel supply", "percentage":0, "hours":0 } }, { "id":4061, "parentId":0, "type":22, "menuId":0, "orderId":13, "visibility":true, "params":{ "description":"Fan", "workingStatus":false, "fanNumber":0, "gear":0, "txtId":null } }, { "id":4062, "parentId":0, "type":23, "menuId":2220, "orderId":6, "visibility":true, "params":{ "description":"Built-in valve", "workingStatus":true, "valveNumber":0, "currentTemp":380, "returnTemp":370, "setTempCorrection":0, "openingPercentage":86, "valvePump":0, "boilerProtection":0, "returnProtection":1, "setTemp":41, "txtId":-1 } }, { "id":4063, "parentId":0, "type":24, "menuId":2270, "orderId":7, "visibility":true, "params":{ "description":"Built-in valve", "workingStatus":true, "valveNumber":1, "currentTemp":390, "returnTemp":370, "setTempCorrection":0, "openingPercentage":78, "valvePump":0, "boilerProtection":0, "returnProtection":0, "setTemp":37, "txtId":-1 } }, { "id":4065, "parentId":0, "type":11, "menuId":0, "orderId":11, "visibility":true, "params":{ "description":"Relay", "workingStatus":false, "txtId":550, "iconId":101 } } ] }