Rule to update sitemap, how?

Hi,
below is the Web UI and the items, sitemap and rulesfiles
i need help with implementation
i want that instead of “Barak At Home” ill see a text saying “Barak is Home” when the iphone is in Home and when iphone is not in home i will see “Barak is out”, Same for Almog iphone
second, why cant i see the last update from the iphones in he UI?

thanks a lot

my items file looks like that:

   /*Groups*/
Group LivingRoom_Group "Living Room"
Group ICloud_Group "iPhones"

    /*Reciver*/
    String   VSX923_DisplayInformationDisplayInformation   "Display"   <text>           (LivingRoom_Group) {channel="pioneeravr:ipAvr2014:5F9EC1B3-ED59-79BB-4530-745e1c317d54:displayInformation#displayInformation"}
    Switch   VSX923_Zone1Power                             "Power"     <switch>         (LivingRoom_Group) {channel="pioneeravr:ipAvr2014:5F9EC1B3-ED59-79BB-4530-745e1c317d54:zone1#power"}
    Dimmer   VSX923_Zone1VolumeDimmer                      "Volume"    <soundvolume>    (LivingRoom_Group) {channel="pioneeravr:ipAvr2014:5F9EC1B3-ED59-79BB-4530-745e1c317d54:zone1#volumeDimmer"}
    Number   VSX923_Zone1VolumeDb                          "Volume"    <soundvolume>    (LivingRoom_Group) {channel="pioneeravr:ipAvr2014:5F9EC1B3-ED59-79BB-4530-745e1c317d54:zone1#volumeDb"}
    Switch   VSX923_Zone1Mute                              "Mute"      <switch>         (LivingRoom_Group) {channel="pioneeravr:ipAvr2014:5F9EC1B3-ED59-79BB-4530-745e1c317d54:zone1#mute"}
    String   VSX923_Zone1SetInputSource                    "Input"     <receiver>       (LivingRoom_Group) {channel="pioneeravr:ipAvr2014:5F9EC1B3-ED59-79BB-4530-745e1c317d54:zone1#setInputSource"}

    /*Barak's Iphone*/
    String   BatteryStatus           "Battery Status"            (ICloud_Group) {channel="icloud:device:8389ea07:d7b5aab3:batteryStatus"}
    Location BarakLocation           "BarakLocation"             (ICloud_Group) {channel="icloud:device:8389ea07:d7b5aab3:location"}
    //Switch   BarakiPhonesRefresh     "BaraK iPhones Refresh"     (ICloud_Group) {channel="icloud:device:8389ea07:d7b5aab3:location", autoupdate="false"}
    Switch   BarakiPhone_Home        "Barak At Home?" <presence> (ICloud_Group)
    DateTime BarakLastUpdate         "Barak Last Update" {channel="icloud:device:8389ea07:d7b5aab3:locationLastUpdate"} 

    /*Almog's Iphone*/
    Location AlmogLocation          "AlmogLocation"              (ICloud_Group) {channel="icloud:device:8389ea07:7a3288b7:location"}
    //Switch   AlmogiPhonesRefresh    "Almog iPhones Refresh"      (ICloud_Group) {channel="icloud:device:8389ea07:7a3288b7:location", autoupdate="false"}
    Switch   AlmogiPhone_Home       "Almog At Home?" <presence>  (ICloud_Group) 
    DateTime AlmogLastUpdate        "Almog Last Update" {channel="icloud:device:8389ea07:7a3288b7:locationLastUpdate"}

my Sitemap file like that:

sitemap default label="Home" {
    Group item=LivingRoom_Group{
        Frame label="Reciver" icon="receiver" {
            Switch item=VSX923_Zone1Power
            Switch item=VSX923_Zone1SetInputSource mappings=[06="Yes", 15="AppleTV", 22="PlayStation"]
            Slider item=VSX923_Zone1VolumeDimmer
            Setpoint item=VSX923_Zone1VolumeDb minValue=-80 maxValue=0 step=1
            Switch item=VSX923_Zone1Mute mappings=[ON="Mute", OFF="Un-Mute"]
        }
    }
    Group item=ICloud_Group{
        //Switch item=BarakiPhoneRefresh mappings=[ REFRESH='Refresh now' ]
        Text  item=BarakiPhone_Home
        //Switch item=AlmogiPhoneRefresh mappings=[ REFRESH='Refresh now' ]
        Text  item=AlmogiPhone_Home
        Text item=AlmogLastUpdate
        Text item=BarakLastUpdate 
    }
}

rules files:

rule "BarakInHouse"
when
    Item BarakLocation changed
then
    // specify your home location
    val PointType home_location  = new PointType(new DecimalType(32.499562682549644), new DecimalType(34.91848117079638))
    val PointType phone_location = BarakLocation.state as PointType
    val int distance = phone_location.distanceFrom(home_location).intValue()
    // specify your preferred radius (in meters)
    if ( distance < 100) {
        BarakiPhone_Home.postUpdate(ON)
        logInfo("Barak Home", "Barak is in the House.")
    } else {
        BarakiPhone_Home.postUpdate(OFF)
        logInfo("Barak Home", "Barak is Out.")
    }
end

rule "AlmogInHouse"
when
    Item AlmogLocation changed
then
    // specify your home location
    val PointType home_location  = new PointType(new DecimalType(32.499562682549644), new DecimalType(34.91848117079638))
    val PointType phone_location = AlmogLocation.state as PointType
    val int distance = phone_location.distanceFrom(home_location).intValue()
    // specify your preferred radius (in meters)
    if ( distance < 100) {
        AlmogiPhone_Home.postUpdate(ON)
        logInfo("Almog Home", "Almog is in the House.")
    } else {
        AlmogiPhone_Home.postUpdate(OFF)
        logInfo("Almog Home", "Almog is Out.")
    }
end

You need to use mappings:

DateTime AlmogLastUpdate        "Almog Last Update [%s]" {channel="icloud:device:8389ea07:7a3288b7:locationLastUpdate"}

You could use the sitemap visibility option to display one of two lines with different labels, depending on the item value

how to use the visibility option?

click here for links to the relevant doc section:

2 Likes