From e7814b889432eb2b30a8ae83bbaafce84b21f9f2 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 4 May 2021 18:18:14 +0200 Subject: [PATCH] change state to 'offline' if device is offline. Sensor changed values to -1 --- FHEM/74_GardenaSmartDevice.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/FHEM/74_GardenaSmartDevice.pm b/FHEM/74_GardenaSmartDevice.pm index c3195e4..38a0676 100644 --- a/FHEM/74_GardenaSmartDevice.pm +++ b/FHEM/74_GardenaSmartDevice.pm @@ -649,7 +649,9 @@ sub WriteReadings { } while ( $settings >= 0 ); readingsBulkUpdate( $hash, 'state', - ReadingsVal( $name, 'mower-status', 'readingsValError' ) ) + ReadingsVal($name , 'device_info-connection_status', 'unknown') eq 'online' ? + ReadingsVal( $name, 'mower-status', 'readingsValError') : 'offline' + ) if ( AttrVal( $name, 'model', 'unknown' ) eq 'mower' ); readingsBulkUpdate( $hash, 'state', @@ -661,16 +663,24 @@ sub WriteReadings { ) ) if ( AttrVal( $name, 'model', 'unknown' ) eq 'watering_computer' ); - readingsBulkUpdate( - $hash, 'state', - 'T: ' + + if ( AttrVal( $name, 'model', 'unknown' ) eq 'sensor' ) { + my $online_state = ReadingsVal($name , 'device_info-connection_status', 'unknown'); + my $state_string = 'T: ' . ReadingsVal( $name, 'ambient_temperature-temperature', 'readingsValError' ) . '°C, H: ' . ReadingsVal( $name, 'humidity-humidity', 'readingsValError' ) . '%, L: ' - . ReadingsVal( $name, 'light-light', 'readingsValError' ) . 'lux' - ) if ( AttrVal( $name, 'model', 'unknown' ) eq 'sensor' ); + . ReadingsVal( $name, 'light-light', 'readingsValError' ) . 'lux'; + + if ( $online_state eq 'offline') { + readingsBulkUpdate( $hash, 'ambient_temperature-temperature', '-1' ); + readingsBulkUpdate( $hash, 'humidity-humidity', '-1' ); + readingsBulkUpdate( $hash, 'light-light', '-1' ); + } + readingsBulkUpdate($hash, 'state', ReadingsVal($name , 'device_info-connection_status', 'unknown') eq 'online' ? $state_string : 'offline' ) + } readingsBulkUpdate( $hash, 'state',