Hi Guys.
I am new to the whole rule writing thing. so please be gentle. LOL
I have worked off of the iCloud binding documents to get the rule in place but it seems not to work correctly (At all ).
Items File.
String iPhone_BatteryStatus "Allen Battery Status [%s]" <battery> (Apple) {channel="icloud:device:myaccount:myiPhone6:batteryStatus"}
Number iPhone_BatteryLevel "Allen Battery Level [%d %%]" <battery> (Apple) {channel="icloud:device:myaccount:myiPhone6:batteryLevel"}
Switch iPhone_FindMyPhone "Allen Trigger Find My iPhone" (Apple) {channel="icloud:device:myaccount:myiPhone6:findMyPhone", autoupdate="false"}
Switch iPhone_Refresh "Allen Force iPhone Refresh" (Apple) {channel="icloud:device:myaccount:myiPhone6:location", autoupdate="false"}
Location iPhone_Location "Allen Coordinates" (Apple) {channel="icloud:device:myaccount:myiPhone6:location"}
Number iPhone_LocationAccuracy "Allen Coordinates Accuracy [%.0f m]" (Apple) {channel="icloud:device:myaccount:myiPhone6:locationAccuracy"}
DateTime iPhone_LocationLastUpdate "Allen Last Update [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]" <time> (Apple) {channel="icloud:device:myaccount:myiPhone6:locationLastUpdate"}
Switch iPhone_Home "Allen Phone Home" <presence> (Apple)
Switch iphone_Work "Allen Phone Work" <presence> (Apple)
String iPhone_BatteryStatus_A "Aletchia Battery Status [%s]" <battery> (Apple) {channel="icloud:device:myaccount:myiPhone8:batteryStatus"}
Number iPhone_BatteryLevel_A "Aletchia Battery Level [%d %%]" <battery> (Apple) {channel="icloud:device:myaccount:myiPhone8:batteryLevel"}
Switch iPhone_FindMyPhone_A "Aletchia Trigger Find My iPhone" (Apple) {channel="icloud:device:myaccount:myiPhone8:findMyPhone", autoupdate="false"}
Switch iPhone_Refresh_A "Aletchia Force iPhone Refresh" (Apple) {channel="icloud:device:myaccount:myiPhone8:location", autoupdate="false"}
Location iPhone_Location_A "Aletchia Coordinates" (Apple) {channel="icloud:device:myaccount:myiPhone8:location"}
Number iPhone_LocationAccuracy_A "Aletchia Coordinates Accuracy [%.0f m]" (Apple) {channel="icloud:device:myaccount:myiPhone8:locationAccuracy"}
DateTime iPhone_LocationLastUpdate_A "Aletchia Last Update [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]" <time> (Apple) {channel="icloud:device:myaccount:myiPhone8:locationLastUpdate"}
Switch iPhone_Home_A "Aletchia Phone Home" <presence> (Apple)
Switch iphone_Work_A "Aletchia Phone Work" <presence> (Apple)
Site map.
Frame label="Appel"{
Text label="Allen" icon="iphone"{
Default item=iPhone_BatteryStatus label="Battery Status [%s]"
Default item=iPhone_BatteryLevel label="Battery Level [%d %%]"
Default item=iPhone_FindMyPhone label="Find My Phone"
Default item=iPhone_Refresh label="Force iPhone Refresh"
Default item=iPhone_LocationAccuracy label="Accuracy [%.0f m]"
Default item=iPhone_LocationLastUpdate label="Last Update [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]"
Default item=iPhone_Home label="Allen Home"
Default item=iphone_Work label="Allen Work"
Mapview item=iPhone_Location height=10
}
Text label="Aletchia" icon="iphone"{
Default item=iPhone_BatteryStatus_A label="Battery Status [%s]"
Default item=iPhone_BatteryLevel_A label="Battery Level [%d %%]"
Default item=iPhone_FindMyPhone_A label="Find My Phone"
Default item=iPhone_Refresh_A label="Force iPhone Refresh"
Default item=iPhone_LocationAccuracy_A label="Accuracy [%.0f m]"
Default item=iPhone_LocationLastUpdate_A label="Last Update [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]"
Default item=iPhone_Home_A label="Aletchia Home"
Default item=iphone_Work_A label="Aletchia Work"
Mapview item=iPhone_Location_A height=10
}
Appel.rules
rule "Allen Home"
when
Item iPhone_Location changed
then
// specify your home location
val PointType home_location = new PointType(new DecimalType(-25.781538), new DecimalType(29.438835))
val PointType phone_location = iPhone_Location.state as PointType
val int distance = phone_location.distanceFrom(home_location).intValue()
// specify your preferred radius (in meters)
if ( distance < 50) {
iPhone_Home.postUpdate(ON)
logInfo("iPhone Home", "Allen is at home.")
} else {
iPhone_Home.postUpdate(OFF)
logInfo("iPhone Home", "Allen is away.")
}
end
rule "Aletchia Home"
when
Item iPhone_Location_A changed
then
// specify your home location
val PointType home_location = new PointType(new DecimalType(-25.781538), new DecimalType(29.438835))
val PointType phone_location_A = iPhone_Location_A.state as PointType
val int distance = phone_location_A.distanceFrom(home_location).intValue()
// specify your preferred radius (in meters)
if ( distance < 50) {
iPhone_Home_A.postUpdate(ON)
logInfo("iPhone Home A", "Aletchia is at home.")
} else {
iPhone_Home_A.postUpdate(OFF)
logInfo("iPhone Home A", "Aletchia is away.")
}
end
rule "Allen Work"
when
Item iPhone_Location changed
then
// specify your home location
val PointType work_location = new PointType(new DecimalType(-25.892756), new DecimalType(29.119740))
val PointType phone_location = iPhone_Location.state as PointType
val int distance = phone_location.distanceFrom(work_location).intValue()
// specify your preferred radius (in meters)
if ( distance < 50) {
iphone_Work.postUpdate(ON)
logInfo("iPhone Work", "Allen is at Work.")
} else {
iphone_Work.postUpdate(OFF)
logInfo("iPhone Work", "Allen is away from Work.")
}
end
rule "Aletchia Work"
when
Item iPhone_Location_A changed
then
// specify your home location
val PointType work_location_A = new PointType(new DecimalType(-25.781538), new DecimalType(29.492352))
val PointType phone_location_A = iPhone_Location_A.state as PointType
val int distance = phone_location_A.distanceFrom(work_location_A).intValue()
// specify your preferred radius (in meters)
if ( distance < 50) {
iphone_Work_A.postUpdate(ON)
logInfo("iPhone Work A", "Aletchia is at Work.")
} else {
iphone_Work_A.postUpdate(OFF)
logInfo("iPhone Work A", "Aletchia is away from Work.")
}
end
What I do get is a error on viscose. like the following.
{
"resource": "/run/user/1000/gvfs/smb-share:server=openhab.local,share=openhab-conf/rules/Appel.rules",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "org.eclipse.xtext.xbase.validation.IssueCodes.duplicate_type",
"severity": 8,
"message": "The type AppelRules is already defined in Appel.rules.",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 2544
}
Then my second point of help is the Mapview on the IOS app. it just shows the pin and gridlines but no map. but if I use the basicUI I get the map with pin.
Help would be appreciated . but if pointed in the right direction I learn more and will be Abel to help others.
Thanks again.