Fhem mit Siri ohne Siriproxy oder jailbreak steuern

Begonnen von xusader, 03 April 2015, 13:01:29

Vorheriges Thema - Nächstes Thema

xusader

Mit Hilfe des mailcheck Moduls und einer kleinen Modifikation kann man Fhem mit Siri steuern.

Das mailcheck Modul prüft nur auf neue Notizen, die Notizen die Über Siri verschickt werden sind aber nicht als neue oder ungelesene Notizen makiert.
Abhilfe schafft eine Änderung im Modul an Zeile  374, ändert man:

my $msg_count = $client->unseen_count||0;

auf:

my $msg_count = $client->unseen_count||1;

werden auch die von Siri verschickten Notizen angezeigt.

Auf dem iOS Gerät muss hierfür in den iCloud Einstellungen der Punkt Notizen aktiviert sein.

Das Fhem Define sieht dann so aus:

define Siri mailcheck imap.mail.me.com <iCloudID> <Passwort> Notes
attr userReadings Subject

oder mit geändertem, angehängtem Modul:

define Siri Siri imap.mail.me.com <iCloudID> <Passwort> Notes
attr userReadings Subject

Dann nur noch ein Notify das die Notizen verarbeitet:

Siri.*Subject:.* {
for ( ($EVENT) =~ (s/Subject: //g) ) {
for ( ($EVENT) =~ (s/an/on/g) ) {
for ( ($EVENT) =~ (s/aus/off/g) ) {
{fhem("set $EVENT")}
}}}
}

und es kann losgehen mit dem Siri Befehl "Notiz <device> an"


justme1968

mir ist nicht ganz klar warum die unseen änderung nötig sein soll. vor allem sollte sie auch zur folge haben das beim neustart wieder alles mails ein event triggern falls sie noch nicht gelöscht wurden.

ob eine mail als unseen gilt legt der imap server fest. nicht der absender der mail.

bist du sicher das bei dir nicht noch jemand/etwas anderes mails auf diesem postfach abruft?

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

xusader

Ich vermute dass die Notizen durch den Sync auf die iOS Geräte nicht als neue Notizen gekennzeichnet sind.
Wenn ich die Notiz direkt über www.icloud.com versende funktioniert es, nicht aber wenn ich über Siri eine Notiz absetze.

HolyMoly

Genialer Ansatz, funktioniert auch schon ganz anständig  :)
Leider sammeln sich nach einer Weile eine Menge unnötiger Notizen an. Pauschal delete_message möchte ich eigentlich nicht verwenden, da ich auch reguläre Notizen habe welche dann verloren gehen würden. Wie hast du das gelöst oder stellt sich das Problem bei dir gar nicht?
FHEM auf Raspi2 & Radxa Rock

HolyMoly

#4
Habe das Problem durch Einführung eines assistent_name/Keyword behoben, in meinem Fall "Celine".
Ein valides Kommando schaut dann bei mir so aus:
Notiz Celine mach die Stehlampe aus  ;)
Kann sein dass man die RegEx für andere Aktionen noch erweitert muss..
Gelöscht werden dann natürlich auch nur Notizen die Celine enthalten.
Ich hänge mal mein erweitertes Modul an.
FHEM auf Raspi2 & Radxa Rock

xusader

@HolyMoly

Gut gemacht. Ich synchronisiere die Notizen über einen anderen E-Mail Account. Deswegen habe ich keine Prüfung auf ein Keyword eingebaut.

juergen012

Hallo, ich versuche fhem mittels SIRI zu steuern.. Leider hatte ich bisher noch keinen Erfolg. Die Notiz wird gelesen. Es wird aber nichts geschaltet. Ich denke, mein Notify ist falsch. Kann mir jemand helfen??
Beste Grüße
Jürgen K.
Fhem unter Proxmox

deluxe41

#7
Hallo,

Ich habe es mit DOIF gelöst,



define Siri_DOIF DOIF ([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Licht" and [Siri2:Subject] =~ "an") (set SW_Wohnzimmer on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Licht" and [Siri2:Subject] =~ "ein") (set SW_Wohnzimmer on)
DOELSEIF
([Siri2:Subject] =~ "Kinderzimmer" and [Siri2:Subject] =~ "Licht" and [Siri2:Subject] =~ "an") (set SW_Kinderzimmer on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Licht" and [Siri2:Subject] =~ "aus") (set SW_Wohnzimmer off)
DOELSEIF
([Siri2:Subject] =~ "Kinderzimmer" and [Siri2:Subject] =~ "Licht" and [Siri2:Subject] =~ "aus") (set SW_Wohnzimmer off)
DOELSEIF
([Siri2:Subject] =~ "Kinderzimmer" and [Siri2:Subject] =~ "Licht" and [Siri2:Subject] =~ "ein") (set SW_Kinderzimmer on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Fernseher" and [Siri2:Subject] =~ "ein") (set FBDECT_16 on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Fernseher" and [Siri2:Subject] =~ "an") (set FBDECT_16 on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Fernseher" and [Siri2:Subject] =~ "aus") (set FBDECT_16 off)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "LED" and [Siri2:Subject] =~ "an") (set LEDWZ on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "LED" and [Siri2:Subject] =~ "ein") (set LEDWZ on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Regal" and [Siri2:Subject] =~ "ein") (set ELRO_00000_D on)
DOELSEIF
([Siri2:Subject] =~ "Wohnzimmer" and [Siri2:Subject] =~ "Regal" and [Siri2:Subject] =~ "an") (set ELRO_00000_D on)


Sent from my iPhone using Tapatalk
Fritzbox 7490 ( USV + Fall Back ), einige HM komponenten,ESPs

juergen012

Fhem unter Proxmox

deluxe41

Hallo juergen012

freut mich wenn das geholfen hat.

mittlerweile mache ich so ziemlich alles mit DOIF.


Sent from my iPhone using Tapatalk
Fritzbox 7490 ( USV + Fall Back ), einige HM komponenten,ESPs

juergen012

hier mal meine Konfiguration, damit es für andere nicht so lange, wie bei mir dauert....
Zunächst die Datei 70_Siri.pm in das FHEM-Verzeichnis kopieren. Dann mittels cpan Mail::IMAPClient cpan IO::Socket::SSL cpan IO::Socket::INET die MailModule installieren. Dauert etwas... Neustart.. Folgendens konfigurieren:

define Siri Siri imap.mail.me.com username password Notes
attr Siri assistent_name Celine
attr Siri delete_message 1
attr Siri userReadings Subject

eventuell in Apple Id (https://appleid.apple.com/de/) anwedungsspezifisches Passwort erstellen.

Jetzt:

define Siri_DOIF DOIF ([Siri:Subject] =~ "Schlafzimmer" and [Siri:Subject] =~ "Licht" and [Siri:Subject] =~ "an") (set SZ_Licht on) DOELSEIF([Siri:Subject] =~ "Schlafzimmer" and [Siri:Subject] =~ "Licht" and [Siri:Subject] =~ "ein") (set SZ_Licht on) DOELSEIF ([Siri:Subject] =~ "Schlafzimmer" and [Siri:Subject] =~ "Licht" and [Siri:Subject] =~ "aus") (set SZ_Licht off) DOELSEIF([Siri:Subject] =~ "Wohnzimmer" and [Siri:Subject] =~ "Licht" and [Siri:Subject] =~ "an") (set WZ_Licht on) DOELSEIF([Siri:Subject] =~ "Wohnzimmer" and [Siri:Subject] =~ "Licht" and [Siri:Subject] =~ "ein") (set WZ_Licht on) DOELSEIF ([Siri:Subject] =~ "Wohnzimmer" and [Siri:Subject] =~ "Licht" and [Siri:Subject] =~ "aus") (set WZ_Licht off)

iPhone: Notiz Celine Wohnzimmer Licht ein (aus)

Habe bei mir den Namen Celine auf Siri geändert..

Klappt wie verrückt.. DANKE an alle für die Hilfe!!!

Beste Grüße
Jürgen K.
Fhem unter Proxmox

Andy89

danke xusader für das Siri Modul und danke juergen012 für die Beschreibung..

Läuft super und macht Laune mithilfe von Doif sich die wildestens Befehle für Siri auszudenken =)

Siri läuft ja auch auf der iWatch (wenn sie denn irgendwann mal ankommt xD), also bin ich mal gespannt, ob diese dann auch Notizen abspeichern kann  ^^ Wenn ja ist dieses Modul noch genialer =)

Beste Grüße
Andy
FHEM 6.0 auf rPi4 docker (mit Alexa & Siri); dbLog, FTUI, Sonos, XiaomiMapCreator auf rPi4 docker;
raspimatic auf rPi3+ > diverse Aktoren und Sensoren;
LGW > (PCA301),EC3000,LaCrosse; MQTT2 > WLAN-Steckdosen,Xiaomi Map;
Harmony Hub;Sonos;Onkyo AVR;RGB WLAN Controller;Netatmo;Withings;Unifi;AMAD

coolice

Bei mir kommt immer Cannot load Modul Siri. Hab schon shutdown restart  gemacht als auch den Pi vom Strom getrennt. Leider ohne Erfolg. Hat jemand eine Idee? Das Modul liegt im FHEM Modulordner

Andy89

hast du reload in der Kommandozeile(heißt das Feld ganz oben auf Fhem so?) genutzt?

reload 70_Siri.pm

Beste Grüße
Andy
FHEM 6.0 auf rPi4 docker (mit Alexa & Siri); dbLog, FTUI, Sonos, XiaomiMapCreator auf rPi4 docker;
raspimatic auf rPi3+ > diverse Aktoren und Sensoren;
LGW > (PCA301),EC3000,LaCrosse; MQTT2 > WLAN-Steckdosen,Xiaomi Map;
Harmony Hub;Sonos;Onkyo AVR;RGB WLAN Controller;Netatmo;Withings;Unifi;AMAD

Ma_Bo

Hallo Leute, würde auch gerne Siri nutzen, leider scheitert es bei mir bei der Installation der Mail Module :

fhem@NUC:~$ sudo cpan Mail::IMAPClient cpan IO::Socket::SSL cpan IO::Socket::INE                                                                                                                     T
Reading '/home/fhem/.cpan/Metadata'
  Database was generated on Wed, 13 May 2015 10:29:02 GMT
Running install for module 'Mail::IMAPClient'
Running make for P/PL/PLOBBES/Mail-IMAPClient-3.35.tar.gz
Checksum for /home/fhem/.cpan/sources/authors/id/P/PL/PLOBBES/Mail-IMAPClient-3.                                                                                                                     35.tar.gz ok

  CPAN.pm: Building P/PL/PLOBBES/Mail-IMAPClient-3.35.tar.gz

The following optional modules were not found:
        Authen::NTLM for Authmechanism 'NTLM'
        Digest::HMAC_MD5 for Authmechanism 'CRAM-MD5'
Optional modules are available from any CPAN mirror, reference:
  http://search.cpan.org/
  http://www.perl.com/CPAN/modules/by-module
  http://www.perl.org/CPAN/modules/by-module

Checking if your kit is complete...
Looks good
Writing Makefile for Mail::IMAPClient
Writing MYMETA.yml and MYMETA.json

(OPTIONAL) For extended tests during 'make test', create a file
'test.txt' in the top level directory of this distribution (the same
directory as the Makefile.PL, etc.).  This file must contain an IMAP
server name or IP (server=...), a user account (user=...), and a
password (passed=...).  A port (port=....) and an authentication
mechanism to be used (authmechanism=...) can also be specified.

Example:

--- BEGIN: test.txt ---
server=localhost
user=mytestuser
passed=mypassword
port=143
--- END: test.txt ---

NOTE: When testing is completed, be sure to remove test.txt (either by
hand or by 'make clean').

  PLOBBES/Mail-IMAPClient-3.35.tar.gz
  make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Warning: Cannot install cpan, don't know what it is.
Try the command

    i /cpan/

to find objects with matching identifiers.
Running install for module 'IO::Socket::SSL'
Running make for S/SU/SULLR/IO-Socket-SSL-2.014.tar.gz
Checksum for /home/fhem/.cpan/sources/authors/id/S/SU/SULLR/IO-Socket-SSL-2.014.tar.gz ok

  CPAN.pm: Building S/SU/SULLR/IO-Socket-SSL-2.014.tar.gz

Should I do external tests?
These test will detect if there are network problems and fail soft,
so please disable them only if you definitely don't want to have any
network traffic to external sites.   [Y/n] [y] y
Checking if your kit is complete...
Looks good
Writing Makefile for IO::Socket::SSL
Writing MYMETA.yml and MYMETA.json
  SULLR/IO-Socket-SSL-2.014.tar.gz
  make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Warning: Cannot install cpan, don't know what it is.
Try the command

    i /cpan/

to find objects with matching identifiers.
IO::Socket::INET is up to date (1.33).
fhem@NUC:~$


Jemand ne Idee...?

Grüße Marcel
NUC mit FHEM, HM Heizungsthermostate, HM Wandthermostate, Intertechno Funksteckdosen, 10" Tablet als Wanddisplay, KeyMatic, Fensterkontakte, Fensterkontakte umgebaut als Wassermelder und Briefkastenmelder, Aussenthermostat, Anwesenheitssteuerung über Fritz Box, Google Home usw. usw.