ich versuche im Moment eine Anwesenheitserkennung via icloud Bindig zu erstellen.
Leider meldet die Rule immer das mein Iphone nicht Zuhause ist.
Kann mir hier jemand helfen an was dies liegt?
Code: Alles auswählen
Thing device iPhone8Plus "Markus iPhone 8 Plus" @ "Apple" [deviceId="ID meines Iphones"]
Code: Alles auswählen
String MarkusIPhone8PlusBatteryStatus "Battery status" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:batteryStatus"}
Number MarkusIPhone8PlusBatteryLevel "Batterieladung" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:batteryLevel"}
Switch MarkusIPhone8PlusLowBattery "Niedriger batteriestatus" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:lowBattery"}
Switch MarkusIPhone8PlusFindMyPhone "Find my phone" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:findMyPhone"}
Location MarkusIPhone8PlusLocation "Location" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:location"}
Number MarkusIPhone8PlusLocationAccuracy "Location accuracy" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:locationAccuracy"}
DateTime MarkusIPhone8PlusLocationLastUpdate "Last location update" (iCloud_Group) {channel="icloud:device:Markus:iPhone8Plus:locationLastUpdate"}
Switch MarkusIPhone8PlusHome "Phone Home" (iCloud_Group)
Switch MarkusIPhone8PlusRefresh "Force iPhone Refresh" (iCloud_Group) {channel="icloud:device:myaccount:myiPhone8:refresh", autoupdate="false"}
Code: Alles auswählen
rule "iPhone Home"
when
Item MarkusIPhone8PlusLocation changed
then
val PointType home_location = new PointType(new DecimalType(48.96), new DecimalType(9.0))
val PointType MarkusIPhone8PlusLocation = MarkusIPhone8PlusLocation.state as PointType
val int distance = MarkusIPhone8PlusLocation.distanceFrom(home_location).intValue()
if ( distance < 200) {
MarkusIPhone8PlusHome.postUpdate(ON)
logInfo("iPhone Home", "iPhone is at home.")
}
else {
MarkusIPhone8PlusHome.postUpdate(OFF)
logInfo("iPhone Home", "iPhone is away.")
}
end