diff --git a/FHEM/36_Shelly.pm b/FHEM/36_Shelly.pm
index 0ebfa561b..c996c3418 100644
--- a/FHEM/36_Shelly.pm
+++ b/FHEM/36_Shelly.pm
@@ -39,7 +39,7 @@ use vars qw{%attr %defs};
sub Log($$);
#-- globals on start
-my $version = "3.0";
+my $version = "3.1";
#-- these we may get on request
my %gets = (
@@ -120,7 +120,8 @@ my %shelly_models = (
"shellyrgbw" => [0,0,4,1],
"shellydimmer" => [0,0,1,1],
"shellyem" => [1,0,0,2],
- "shellybulb" => [0,0,1,1]
+ "shellybulb" => [0,0,1,1],
+ "shellyuni" => [2,0,0,1]
);
my %shelly_regs = (
@@ -345,7 +346,7 @@ sub Shelly_Attr(@) {
#---------------------------------------
}elsif ( ($cmd eq "set") && ($attrName =~ /mode/) ) {
- if( $model !~ /shelly(2|(rgb|bulb)).*/ ){
+ if( defined($model) && $model !~ /shelly(2|(rgb|bulb)).*/){
Log3 $name,1,"[Shelly_Attr] setting the mode attribute only works for model=shelly2|shelly2.5|shellyrgbw|shellybulb";
return
}
@@ -567,9 +568,9 @@ sub Shelly_Set ($@) {
}
#-- commands strongly dependent on Shelly type
- #-- we have a Shelly 1,4 or ShellyPlug switch type device
+ #-- we have a Shelly 1, Uni, 4 or ShellyPlug switch type device
#-- or we have a Shelly 2 switch type device
- if( ($model =~ /shelly1.*/) || ($model eq "shelly4") || ($model eq "shellyplug") || (($model =~ /shelly2.*/) && ($mode eq "relay")) ){
+ if( ($model =~ /shelly1.*/) || ($model eq "shellyuni") || ($model eq "shelly4") || ($model eq "shellyplug") || (($model =~ /shelly2.*/) && ($mode eq "relay")) ){
#-- WEB asking for command list
if( $cmd eq "?" ) {
@@ -1054,7 +1055,7 @@ sub Shelly_pwd($){
readingsBulkUpdateIfChanged($hash,"network","connected to {TCPIP}."\">".$hash->{TCPIP}."",1);
#-- we have a Shelly 1/1pw, Shelly 4, Shelly 2/2.5, ShellyPlug or ShellyEM switch type device
- if( ($model =~ /shelly1.*/) || ($model eq "shellyplug") || ($model eq "shelly4") || ($model eq "shellyem") || (($model =~ /shelly2.*/) && ($mode eq "relay")) ){
+ if( ($model =~ /shelly1.*/) || ($model eq "shellyuni") || ($model eq "shellyplug") || ($model eq "shelly4") || ($model eq "shellyem") || (($model =~ /shelly2.*/) && ($mode eq "relay")) ){
for( my $i=0;$i<$channels;$i++){
$subs = (($channels == 1) ? "" : "_".$i);
$ison = $jhash->{'relays'}[$i]{'ison'};
@@ -1225,11 +1226,11 @@ sub Shelly_pwd($){
#-- common to all Shelly models
my $hasupdate = $jhash->{'update'}{'has_update'};
my $firmware = $jhash->{'update'}{'old_version'};
- $firmware =~ /.*\/(.*)\@.*/;
+ $firmware =~ /.*\/(v[0-9.]+(-rc\d|)).*/;
$firmware = $1;
if( $hasupdate ){
my $newfw = $jhash->{'update'}{'new_version'};
- $newfw =~ /.*\/(.*)\@.*/;
+ $newfw =~ /.*\/(v[0-9.]+(-rc\d|)).*/;
$newfw = $1;
$firmware .= "(update needed to $newfw)";
}
@@ -1243,6 +1244,19 @@ sub Shelly_pwd($){
readingsBulkUpdateIfChanged($hash,"cloud","disabled");
}
+ #-- look for external sensors
+ if ($jhash->{'ext_temperature'}) {
+ my %sensors = %{$jhash->{'ext_temperature'}};
+ foreach my $temp (keys %sensors){
+ readingsBulkUpdate($hash,"temperature_".$temp,$sensors{$temp}->{'tC'});
+ }
+ }
+ if ($jhash->{'ext_humidity'}) {
+ my %sensors = %{$jhash->{'ext_humidity'}};
+ foreach my $hum (keys %sensors){
+ readingsBulkUpdate($hash,"humidity_".$hum,$sensors{$hum}->{'hum'});
+ }
+ }
readingsEndUpdate($hash,1);
#-- cyclic update
@@ -1619,14 +1633,14 @@ sub Shelly_updown2($){
set the value of a configuration register
set <name> on|off|toggle [<channel>]
set <name> on-for-timer|off-for-timer <time> [<channel>]
- set <name> xtrachannels
attr <name> shellyuser <shellyuser>
attr <name> model generic|shelly1|shelly1pm|shelly2|shelly2.5|shelly4|shellyplug|shellydimmer|shellyrgbw
+ attr <name> model generic|shelly1|shelly1pm|shelly2|shelly2.5|shellyuni|shelly4|shellyplug|shellydimmer|shellyrgbw
attr <name> mode relay|roller (only for model=shelly2/2.5) mode white|color (only for model=shellyrgbw)