- Offizieller Beitrag Autor
© 2020 Stefan K. (aka 66er)
Today I can introduce the integration of the temperature addon with sensor DHT22 on Shelly1.
Requirement:
The coupling requires an existing integration of a Shelly1 according to these instructions. It has been tested on Shelly1, but should also work 1: 1 on the Shelly1PM (without guarantee).
Implementation:
First of all we need a system variable for the values "temperature" and "humidity" of the addon, which is linked to the corresponding Shelly1.
You can freely choose the variable names, but they cannot contain spaces!
Now all you need is a script that is inserted in the update program (see coupling instructions Shelly1) as another THEN line:
!Skript V1.0 zur Werteaktualisierung des Temp-Addon mit 1x DHT22 mit Originalfirmware (c)2020 by 66er (alias Stefan K.)
!***********************************************************************
!Raumbezeichnung (nur zur Orientierung, ggf anpassen)
!**** SETUP ******** SETUP ******** SETUP ******** SETUP ***
! ACHTUNG: Beim Anpassen der Adressen keine "" löschen!
! Setup der CUxD-GERÄTE
var url = "http://192.168.1.150/status"; ! IP-Adresse des Shelly mit Temp-Addon anpassen
var execta = "CUxD.CUX2801001:2"; ! Adresse und Kanal des CUxD-Exec-Device angeben
!Setup der SYSTEMVARIABLEN
var temp = "Shelly-TA_aussen_Temp"; !Name der Systemvariablen für die Temperatur anpassen
var hum = "Shelly-TA_aussen_Lf"; ! Name der Systemvariablen für die Luftfeuchte anpassen
!Setup der OFFSET-Werte
!*** OFFSET Werte unbedingt im Format x.x (Punkt statt Komma!) eingeben
var offsettemp = "0.0"; ! Offset Temperatur
var offsethum = "0.0"; ! Offset Luftfeuchte
!****ENDE SETUP ********ENDE SETUP ********ENDE SETUP ******
!*****Ab hier NICHTS MEHR ÄNDERN *****
!****Abfrage des Temp-Addon****
dom.GetObject(""#execta#".CMD_SETS").State("wget -q -O - '"#url#"'");
dom.GetObject(""#execta#".CMD_QUERY_RET").State(1);
string Antwort = dom.GetObject(""#execta#".CMD_RETS").State();
string t = dom.GetObject(""#execta#".CMD_RETS").State();
dom.GetObject(""#execta#".CMD_SETS").State("0");
!WriteLine(Antwort);
! Auslesen Temperatur
string word = "tC";
integer word_laenge = word.Length();
integer word_position = Antwort.Find(word);
string daten = Antwort.Substr((word_position + word_laenge +2), 4);
integer word_position = daten.Find(word);
daten = daten.Substr(0, (word_position -3));
WriteLine(daten); ! = Temperatur
t = daten.ToFloat() + offsettemp;
!WriteLine(t);
! Auslesen Luftfeuchte
string word = "hum";
integer word_laenge = word.Length();
integer word_position = Antwort.Find(word);
string daten = Antwort.Substr((word_position + word_laenge +19), 5);
integer word_position = daten.Find(word);
daten = daten.Substr(0, (word_position -3));
!WriteLine(daten); ! = Luftfeuchte
var h = daten.ToFloat() + offsethum;
!WriteLine(h);
!Werte in Variablen schreiben
dom.GetObject(""#temp#"").State(t);
dom.GetObject(""#hum#"").State(h);
! Ende Skript
Alles anzeigen
I strongly recommend integrating the online status of the Shelly1 in the IF in the update program so that the script is only executed when the Shelly is online. Otherwise there may be delays in the overall process of the Homematic installation!
Have fun with it