From ea333b3a75902535a2b4384d72a3236676ff6e23 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Mon, 10 Aug 2015 13:40:09 +0200 Subject: [PATCH] =?UTF-8?q?Informations=20Flow,=20Readingsync=20bei=20setz?= =?UTF-8?q?en=20von=20diversen=20Set=20States=20verbessert.=20Fehlerberein?= =?UTF-8?q?igung=20-=20Abst=C3=BCrze=20von=20FHEM=20bei=20falschen=20Porta?= =?UTF-8?q?ngaben=20oder=20IP's?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 74_AMAD.pm | 21 +++- .../[Automagic]_Information_Flow_Handy | 98 +++++++++++++++++++ .../[Automagic]_Information_Flow_Tablet | 97 ++++++++++++++++++ 3 files changed, 213 insertions(+), 3 deletions(-) create mode 100644 Flow_Updates/[Automagic]_Information_Flow_Handy create mode 100644 Flow_Updates/[Automagic]_Information_Flow_Tablet 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