diff --git a/74_AMAD.pm b/74_AMAD.pm
index b9c83d9..e00e00f 100644
--- a/74_AMAD.pm
+++ b/74_AMAD.pm
@@ -22,7 +22,7 @@
#
################################################################
-###### Version 0.2.0 ############
+###### Version 0.2.1 ############
@@ -77,7 +77,7 @@ sub AMAD_Define($$) {
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "AMAD_GetUpdateTimer", $hash, 0);
- $hash->{STATE} = "active";
+ $hash->{STATE} = "initialized";
readingsSingleUpdate ($hash,"deviceState","online",0);
return undef;
@@ -140,7 +140,7 @@ sub AMAD_GetUpdateTimer($)
my ($hash) = @_;
my $name = $hash->{NAME};
- AMAD_RetrieveAutomagicInfo($hash) if (ReadingsVal($name,"deviceState","online") eq "online" && $hash->{STATE} eq "active");
+ AMAD_RetrieveAutomagicInfo($hash) if (ReadingsVal($name,"deviceState","online") eq "online" && $hash->{STATE} eq "active" || $hash->{STATE} eq "error" || $hash->{STATE} eq "initialized");
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "AMAD_GetUpdateTimer", $hash, 1);
Log3 $name, 4, "AMAD ($name) - Call AMAD_GetUpdateTimer";
@@ -239,6 +239,7 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$)
if (defined($err)) {
if ($err ne "")
{
+ $hash->{STATE} = "error" if ($hash->{STATE} ne "initialized");
Log3 $name, 4, "AMAD ($name) - AMAD_RetrieveAutomagicInfoFinished: error while requesting AutomagicInfo: $err";
return;
}
@@ -246,6 +247,7 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$)
if($data eq "" and exists($param->{code}))
{
+ $hash->{STATE} = "error" if ($hash->{STATE} ne "initialized");
Log3 $name, 4, "AMAD ($name) - AMAD_RetrieveAutomagicInfoFinished: received http code ".$param->{code}." without any data after requesting AMAD AutomagicInfo";
return;
}
@@ -267,6 +269,8 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$)
}
readingsEndUpdate($hash, 1);
+ $hash->{STATE} = "active" if ($hash->{STATE} eq "error" || $hash->{STATE} eq "initialized");
+
return undef;
}
@@ -277,6 +281,17 @@ sub AMAD_HTTP_POST($$)
my $state = $hash->{STATE};
+ if ($hash->{STATE} eq "initialized")
+ {
+ Log3 $name, 4, "AMAD ($name) - AMAD_HTTP_POST: set command only works if STATE active, please wait next interval run";
+ return;
+ }
+ if ($hash->{STATE} eq "error")
+ {
+ Log3 $name, 4, "AMAD ($name) - AMAD_HTTP_POST: error while send Set command. Please check IP or PORT";
+ return;
+ }
+
$hash->{STATE} = "Send HTTP POST";
HttpUtils_NonblockingGet(
diff --git a/Flow_Updates/[Automagic]_Information_Flow_Handy b/Flow_Updates/[Automagic]_Information_Flow_Handy
new file mode 100644
index 0000000..62030a4
--- /dev/null
+++ b/Flow_Updates/[Automagic]_Information_Flow_Handy
@@ -0,0 +1,98 @@
+
+
+
+ true
+ HTTP Request: /automagic/deviceInfo, Port 8089
+ true
+ /automagic/deviceInfo
+ 8089
+ true
+
+
+ true
+ Akku Ladestand: grösser als 0%
+ 0
+ HIGHER_THAN
+
+
+ false
+ HTTP Response
+ powerLevel {battery_percentage}@@powerPlugged {battery_plugged}@@volumeMusikSpeaker {volumeMusikSpeaker}@@networkCountryIso {network_country_iso}@@voiceMailNumber {voice_mail_number}@@screenBrightness {screenBrightness}@@nextAlarmDay {next_alarmday}@@nextAlarmTime {next_alarmtime}
+ true
+ text/html
+
+
+ true
+ Initialisiere Variable Nächster Alarm: Variable next_alarm
+ next_alarm
+
+
+ true
+ Initialisiere Variable Systemeinstellung: System screen_brightness to screenBrightness
+ SYSTEM
+ screen_brightness
+ screenBrightness
+
+
+ true
+ Initialisiere Variable Systemeinstellung: System volume_music_speaker to volumeMusikSpeaker
+ SYSTEM
+ volume_music_speaker
+ volumeMusikSpeaker
+
+
+ true
+ Initialisiere Variablen Telefoninfo: network_country_iso, voice_mail_number
+ true
+ network_country_iso
+ true
+ voice_mail_number
+
+
+ true
+ Pause: 2s (Gerät wach halten)
+ 2s
+ true
+
+
+ true
+ Script: next_alarmday = "{next_alarm,dateformat,c}"
+
+
+
+ true
+ Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}"
+
+
+
+ Informationen
+ FHEM Info / Steuerung über AMAD Modul
+ true
+ PARALLEL
+ Akku Ladestand: grösser als 0%
+ Initialisiere Variable Nächster Alarm: Variable next_alarm
+ HTTP Response
+ Initialisiere Variablen Telefoninfo: network_country_iso, voice_mail_number
+ Initialisiere Variable Systemeinstellung: System volume_music_speaker to volumeMusikSpeaker
+ Initialisiere Variable Systemeinstellung: System screen_brightness to screenBrightness
+ Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}"
+ Script: next_alarmday = "{next_alarm,dateformat,c}"
+ Pause: 2s (Gerät wach halten)
+
+ HTTP Request: /automagic/deviceInfo, Port 8089
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Flow_Updates/[Automagic]_Information_Flow_Tablet b/Flow_Updates/[Automagic]_Information_Flow_Tablet
new file mode 100644
index 0000000..134d2d9
--- /dev/null
+++ b/Flow_Updates/[Automagic]_Information_Flow_Tablet
@@ -0,0 +1,97 @@
+
+
+
+ true
+ HTTP Request: /automagic/deviceInfo, Port 8089
+ true
+ /automagic/deviceInfo
+ 8089
+ true
+
+
+ true
+ Akku Ladestand: grösser als 0%
+ 0
+ HIGHER_THAN
+
+
+ false
+ HTTP Response
+ powerLevel {battery_percentage}@@powerPlugged {battery_plugged}@@volumeMusikBluetooth {volumeMusikBluetooth}@@volumeMusikSpeaker {volumeMusikSpeaker}@@screenBrightness {screenBrightness}@@nextAlarmTime {next_alarmtime}@@nextAlarmDay {next_alarmday}
+ true
+ text/html
+
+
+ true
+ Initialisiere Variable Nächster Alarm: Variable next_alarm
+ next_alarm
+
+
+ true
+ Initialisiere Variable Systemeinstellung: System screen_brightness to screenBrightness
+ SYSTEM
+ screen_brightness
+ screenBrightness
+
+
+ true
+ Initialisiere Variable Systemeinstellung: System volume_music_bt_a2dp to volumeMusikBluetooth
+ SYSTEM
+ volume_music_bt_a2dp
+ volumeMusikBluetooth
+
+
+ true
+ Initialisiere Variable Systemeinstellung: System volume_music_speaker to volumeMusikSpeaker
+ SYSTEM
+ volume_music_speaker
+ volumeMusikSpeaker
+
+
+ true
+ Pause: 2s (Gerät wach halten)
+ 2s
+ true
+
+
+ true
+ Script: next_alarmday = "{next_alarm,dateformat,c}"
+
+
+
+ true
+ Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}"
+
+
+
+ Informationen
+ FHEM Info / Steuerung über AMAD Modul
+ true
+ PARALLEL
+ Akku Ladestand: grösser als 0%
+ Initialisiere Variable Nächster Alarm: Variable next_alarm
+ Initialisiere Variable Systemeinstellung: System volume_music_bt_a2dp to volumeMusikBluetooth
+ Initialisiere Variable Systemeinstellung: System volume_music_speaker to volumeMusikSpeaker
+ Initialisiere Variable Systemeinstellung: System screen_brightness to screenBrightness
+ Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}"
+ Script: next_alarmday = "{next_alarm,dateformat,c}"
+ Pause: 2s (Gerät wach halten)
+
+ HTTP Request: /automagic/deviceInfo, Port 8089
+
+ HTTP Response
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file