- Offizieller Beitrag
©2019-2020 Stefan K. (alias 66er)
All rights reserved!
Hello everybody,
In order to integrate the Shelly1 in Homematic, you do not need any third-party firmware that you have to flash.
Below I present my solution with the original firmware:
Possibilities:
- turn on
- turn off
- status display
- Update in freely adjustable interval (important, if, for example, switched in parallel via Shelly-App or Shelly-Timer)
- use in programs
- optional monitoring of the accessibility of the Shelly in the network (online status)
technically requirements:
- compatible with the homematic systems CCU2, CCU3, Charly, as well as all offshoots like RaspberryMatic and piVCCU.
- installed add-on CUxD in current version
(The knowledge about the handling CUxD, such as devices create, I assume at this point, otherwise "exploded" this guide. Thank you for understanding.)
Implementation:
(On the description of the creation of the CUxD devices I give up at this point, but there is the CUxD document!)
If not yet available, please create a device (28) System Exec! Above that the commands are issued.
Creating a CUxD (40) 16-channel universal control as a switch:
Settings of the individual channels (1 channel = 1 Shelly)
Setting for SWITCH | CMD_SHORT:
Setting for SWITCH|CMD_LONG
Adjust IP address of each to your own Shelly1
Now,switching ON and OFF is working.
For the status update you need a CUxD timer in addition to the CUxD-Exec.
Addendum:
You can dispense with this since firmware 1.5.0, if you use the "Actions" in the Shelly to update the status. Pros and cons were discussed in this thread.
Also the mechanism of the actions is described there.
The desired update time (here 30 seconds) is entered in the timer:
Now you need 1 program that updates the switch status cyclically:
Programm Shelly aktualisieren.JPG
Of course, the additional IF-exams are optional and adapted to my setup. Functionally, only the 1st IF line must be in the program.
And if the program does not trigger using "Timerevent", you can instead
"at Timerget in the range smaller1 - when changed"
trigger.
The just missing script:
!Skript V2.1 zur Statusaktualisierung Shelly1 mit Originalfirmware (c) 2020 by 66er (alias Stefan K.)
!Raumbezeichnung: WeFi (kann angepasst werden)
!**** SETUP ******** SETUP ******** SETUP ******** SETUP ***
! ACHTUNG: Beim Anpassen der Adressen keine "" löschen!
! Setup der CUxD-GERÄTE
var url = "http://192.168.1.126/relay/0/status"; ! IP-Adresse des Shelly 1 anpassen
var execo = "CUxD.CUX2801001:2"; ! Adresse und Kanal des CUxD-Exec-Device angeben
var shellyo = "CUxD.CUX4000005:3" ; ! Adresse und Kanal des CUxD-Device für den Shelly 1 anpassen
!****ENDE SETUP ********ENDE SETUP ********ENDE SETUP ******
!*****Ab hier NICHTS MEHR ÄNDERN *****
dom.GetObject(""#execo#".CMD_SETS").State("wget -q -O - '"#url#"'");
dom.GetObject(""#execo#".CMD_QUERY_RET").State(1);
string Antwort = dom.GetObject(""#execo#".CMD_RETS").State();
dom.GetObject(""#execo#".CMD_SETS").State("0");
!WriteLine(Antwort);
string word = "ison:";
integer word_laenge = word.Length();
integer word_position = Antwort.Find(word);
string daten = Antwort.Substr((word_position + word_laenge +4), 5);
integer word_position = daten.Find(word);
daten = daten.Substr(0, (word_position -3));
Antwort = "true";
!WriteLine(daten);
var zustand = dom.GetObject(""#shellyo#".STATE").State();
!WriteLine(zustand);
if ((daten == "true,") && (zustand != true) )
{dom.GetObject(""#shellyo#".SET_STATE").State(1);
!WriteLine("if ON");
}
if ((daten == "false") && (zustand != false)) {
dom.GetObject(""#shellyo#".SET_STATE").State(0);
!WriteLine("if off");
}
daten = "0";
!Ende Skript
Alles anzeigen
Attention:
To adapt are the adresses in the setup-area!
With a refresh interval of 30 seconds and currently 3 Shelly1, there is no major change in CCU3 utilization.
Optional monitoring of the online status of the Shelly1
(Availability in the (W) LAN)
Here's the result in advance:
(So here everyone can decide for themselves whether the topic is relevant for individual and will be pursued)
Advantages of optional monitoring:
- failure monitoring
- Online status visible in the already created "CUxD Shelly device"
- Possibility to individually respond to unavailability of a Shelly1, e.g. with e-mail notification, display or similar
- Project-dependent additional influence on the switching state of the "CUxD-Shelly"
What is needed in addition to the previous setup:
- 1 CUxD device (28) Ping (1channel / Shelly1)
- 1 system variable per Shelly1
The system variable (s):
For each Shelly, 1 system variable of type Logic is created:
and linked to the corresponding channel of the "CUxD-Shelly".
This makes the variable visible in the CUxD device (to be seen in the picture)
The variable is controlled directly by the device "CUxD-Ping". (It makes sense to assign the channels 1: 1 to the Shellys as in the CUxD switch.)
Now there are 2 possibilities:
1. Only display online status
For each Shelly1, the assigned CUxD ping channel must be set as follows:
The times can be changed. (As long as your system does not go to their knees. )
SWITCH | IP_DNS_ADR: Customize the Shelly's IP
SWITCH | CMD_EXEC_TRUE:
SWITCH|CMD_EXEC_FALSE:
Attention: In both codes ...
Replace "Onlinestatus_Shelly_Fitnessraum" with the name of your system variable! (Attention: do not use spaces in the name!)
Now, the CUxD ping monitors the Shelly1 and updates the status online / offline in the system variable automatically.
If the status of the system variable does not match the real online status after creation, then the real online status must be changed once (eg by switching off the Shelly). After waiting for the monitoring time, set in the PING, and switching on the Shelly, the state will be updated.
2. additionally with "Offline" status, set the Shelly CUxD switch to the "OFF" position
(without unnecessarily sending commands to the network)
Meaning and purpose:
Due to the lack of N-conductors in the switch boxes, I installed my Shelly1 in the lamps. If the light is switched off accidentally (or intentionally) via the conventional switch, not only is the light off, but also the Shelly1 (= offline). However, the CCU would not notice that, leaving the CUxD switch in state 1.
A 2nd command in the SWITCH | CMD_EXEC_FALSE code allows the CUxD Shelly switch channel to be turned OFF without sending unnecessary commands to the network. Overall, the extended entry looks like this:
extra/timer.tcl Onlinestatus_Shelly_Fitnessraum 0; extra/timer.tcl CUxD.CUX4000005:1.SET_STATE 0
Replace "Onlinestatus_Shelly_Fitnessraum" with the name of your system variable! (Attention: do not use spaces in the name!)
In addition, please adjust the CUxD address of the Shelly switching channel!
The extended command line now also sets the switch to OFF position in addition to the status in the system variable in OFFLINE.
(SWITCH | CMD_EXEC_TRUE does not need to be extended, because with state ONLINE the switching state of the Shelly1 is updated anyway.)
Have fun with it
____________________________________________________________
The instructions including the scripts and pictures are subject to copyright. Anyone who infringes the copyright (for example, pictures or texts illegally copied and published on other websites), according to §§ 106 ff UrhG punishable, can also be warned for a fee and must pay damages (§ 97 UrhG).
© 2019-2020 Stefan K. (aka 66er)
All rights reserved
____________________________________________________________
Do you like the instructions? Would you like to reward the effort involved with a small "thank you"?
I am happy about every thank you PayPal (send money to a friend): der-66er@web.de
Many thanks.