Status of things in sitemap?

To put anything in a sitemap, you need to capture it into an Item.
The rules earlier show how to do that.

How to get a result like the following on the sitemap?
Power
with the switch icon changing to “red” for any thing status other than “online”?

How to get rid of the “dash”?

Even better would be to state the things status as text as visible in PaperUI… (no need for the switch icon in such case), e.g. Online or Offline in green/red color

For some reason the switch icon doesn’t change to “red” when the Fritzbox is diconnected.
Do I need to ping it somehow or what would be the refresh rate by default?

In which log file can I find the Info and Error messages?

I use the following rule:

rule "FRITZ!Box (Modem) Status"
when
  Thing "avmfritz:fritzbox:192_168_0_1" changed 
then
      var thingStatusInfo = getThingStatusInfo("avmfritz:fritzbox:192_168_0_1")
if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) {
    logInfo("ThingStatus", "ONLINE")
  fritzbox_modem_status.postUpdate(ON)
} else {
    logError("ThingStatus", "OFFLINE")
  fritzbox_modem_status.postUpdate(OFF)
}
end

item

String fritzbox_modem_status "FRITZ!Box" <switch>

sitemap

Text item=fritzbox_modem_status

Thx.

Text item=fritzbox_modem_status valuecolor=[=="Offline"="red", =="Online"="green"]
1 Like

How to transfer the strings “Online” or “Offline” to the item?
How does this work with postUpdate?

Thx.

Which Item?
This one?

This is an Item of type String.
To update the state of any Item, you can use the .postUpdate method.
In the case of a String Item, you should postUpdate a string value

fritzbox_modem_status.postUpdate("Online")

I’m still struggeling with the Thing Status showing in the sitemap… I was then trying another approach using a cron job to obtain thing status on a regular basis instead of a rule on thing status change. By that I should be able to set the time interval of the cron job for each thing separately. e.g. network device more frequently, Zwave less frequently. That’s the idea.

In some input in this thread:

In order to test the basic logic, I was just trying to get the the string “Online” to show in the sitemap and used the following rule…

rule "FRITZ!Box (Modem) Status"
  when
    Time cron "0 * * ? * * *"
  then
    fritzbox_modem_status.postUpdate("Online")
end

Item:

String fritzbox_modem_status

Sitemap:

Text item=fritzbox_modem_status label="FRITZ!Box (Modem)" icon="none"

No string appears in the sitemap.

What is wrong?

You have asked for the state not to be displayed. Try -

Text item=fritzbox_modem_status label="FRITZ!Box (Modem) [%s]" icon="none"

This solved the issue. Thank you.

Will continue to work on the rule to actually show the Thing status with a cron job…

Since thing status of the network binding is not reliable (always shows “Online”, even though device is switched off), I would like to use a workaround with ping…
The latency value in ms from the network binding seems to be a much better indicator for the thing status.

Idea: after successful ping -> “ONLINE”, else “OFFLINE”
e.g. if ping value is greater or equal 0, then “ONLINE” else “OFFLINE”.

Unfortunately, the following rule doesn’t work:

rule "Mesh2 Status"
  when
    Time cron "0 * * ? * * *"
  then
    if (network_pingdevice_726a2714_latency >= 0)
    mesh2_status.postUpdate("ONLINE")
    else
    mesh2_status.postUpdate("OFFLINE")
end

Item:

String mesh2_status

Sitemap:

Text item=mesh2_status label="Mesh 2 [%s]" icon="none" valuecolor=[=="OFFLINE"="red", =="ONLINE"="green"]

What is wrong?

Seems pointless triggering on cron when you are offered triggers for Item changing. If it hasn’t changed, what use is running the rule again …

I’m guessing that is an Item. An Item is a complex object with name, label, etc. I expect what you’re interested in is its state.

But - if you are using the network binding to a ping, why not just use the switch type channel conveniently provided?

You’re right! Thank you!

I had thought that the …_online switch item from the network binding is as unreliable as the thing status from it. But it is as reliable as the _latency item.

I use the following rule which is working - even after system startup:

rule "Mesh2 Status"
  when
    System started or Item network_pingdevice_726a2714_online changed 
  then
    if (network_pingdevice_726a2714_online.state == ON) {
      mesh2_status.postUpdate("ONLINE")
      mesh2_statusdetail.postUpdate("PING_SUCCESS")
    }
    else {
      mesh2_status.postUpdate("OFFLINE")
      mesh2_statusdetail.postUpdate("PING_FAILED")
    }
end

The switch channel is provided to indicate the target’s status.

The status of a Thing is internal openHAB business. Are the resources available that are needed to attempt to ping that target? It’s not a results holder. That’s what channels and Items are for.

Not sure I understand your question. WHat do you mean by “resources” in this contaxt? Computing resources?

My main target was to get a reliable thing status.
This is highly unreliable for things via network binding. e.g. showing “Online” even if the device (thing) is switched off. I don’t think that the thing status is purely openHAB business. There are several threads about this indicating issues with thing status with the network binding - at least a relation seems to exist.
Therefore I was trying to find a workaround for it.
The _online switch items from things via network binding work for me to achieve this.

You misunderstand what the Thing tepresents here. It’s not a model of a target device. It’s something the netwrk binding can use to query the device.
Hence my rhetorical. Am I (openHAB) able to ping that target? Yes. Then the Thing is available. Whether the target eventually responds or not isn’t really important to the binding to carry out the task.

The results of that ping are of course made available to you to make your own model of the target. Usually a switch for a go/nogo indicator.

getThingStatusInfo() always generates an error:

var thingStatusInfo = getThingStatusInfo(“zwave:device:512:node5”)

An error occured during the script execution: The name ‘getThingStatusInfo()’ cannot be resolved to an item or type.

It doesn’t matter if the thing exists or not. It generates the same error every time.

Any ideas?

You need to have Thing Actions installed, but I thought they were part of core and always in. Your OH version?

In some versions, this was needed
ThingAction.getThingStatusInfo( xxx )

ThingAction.getThingStatusInfo gives me the same error.

My version shows 2.0.0.b5 when it starts up.

Ah right, I don’t think these features arrived until 2.4 (the current stable version)

@rossko57 Thanks for your help. It sounds like it is finally time to upgrade. Fingers crossed that nothing breaks to bad. Any pointers on making a smooth upgrade? I’m running on Windows.

2.0 to 2.4 is quite a step. I think I’d backup everything, start a fresh install, and restore my items/rules/things etc. Personal choice.

It is possible a 2.5 stable will be out for a Christmas project.