Thank you for your suggestions.
Well, it seems as if there is no direct way to set the item’s state…
Worth noting that the IP address is already part of the thing configuration of a Network binding thing (configuration/hostname). Maybe some way to retrieve it?
It would be elegant to:
- fetch this data somehow from the thing configuration and
- transfer it somehow directly to the item’s state
… thereby making sure the shown IP address is always up to date in the UI.
My findings so far…
REST API request URL:
http://192.168.0.13:8080/rest/things/network%3Apingdevice%3Abcbd2958ed
provides:
{
"channels": [
{
"linkedItems": [
"KostalWechselrichterPing_Online"
],
"uid": "network:pingdevice:bcbd2958ed:online",
"id": "online",
"channelTypeUID": "network:online",
"itemType": "Switch",
"kind": "STATE",
"label": "Online",
"description": "Gibt an ob das Gerät aktuell online oder offline ist.",
"defaultTags": [],
"properties": {},
"configuration": {}
},
{
"linkedItems": [
"KostalWechselrichterPing_Pingzeit"
],
"uid": "network:pingdevice:bcbd2958ed:latency",
"id": "latency",
"channelTypeUID": "network:latency",
"itemType": "Number:Time",
"kind": "STATE",
"label": "Pingzeit",
"description": "Gibt an wie lange ein Ping in Millisekunden an das Gerät dauert.",
"defaultTags": [],
"properties": {},
"configuration": {}
},
{
"linkedItems": [
"KostalWechselrichterPing_Zuletztgesehen"
],
"uid": "network:pingdevice:bcbd2958ed:lastseen",
"id": "lastseen",
"channelTypeUID": "network:lastseen",
"itemType": "DateTime",
"kind": "STATE",
"label": "Zuletzt gesehen",
"description": "Gibt Zeit/Datum an wann das Gerät zuletzt gesehen wurde.",
"defaultTags": [],
"properties": {},
"configuration": {}
}
],
"statusInfo": {
"status": "ONLINE",
"statusDetail": "NONE"
},
"editable": true,
"label": "Kostal Wechselrichter (Ping)",
"configuration": {
"hostname": "192.168.0.10",
"refreshInterval": 60000,
"retry": 2,
"timeout": 5000
},
"properties": {
"icmp_state": "IPUTILS_LINUX_PING",
"dhcp_state": "Bound to port 6767 - Port forwarding necessary !",
"presence_detection_type": "",
"arp_state": "Unknown arping tool",
"uses_ios_wakeup": "Yes"
},
"UID": "network:pingdevice:bcbd2958ed",
"thingTypeUID": "network:pingdevice"
}
Alternatively the IP address is also shown in Main UI (Thing → Code):
UID: network:pingdevice:bcbd2958ed
label: Kostal Wechselrichter (Ping)
thingTypeUID: network:pingdevice
configuration:
hostname: 192.168.0.10
refreshInterval: 60000
retry: 2
timeout: 5000
There seem to be another way to somehow get the IP address via the Thingshandler…
+++
Things can be configured with parameters. To retrieve the configuration of a Thing one can call getThing().getConfiguration()
inside the ThingHandler
. The configuration class has the equivalent methods as the Map
interface, thus the method get(String key)
can be used to retrieve a value for a given key.
+++
Item’s stateDescription can hold a transformation:
+++
Pattern or transformation applied to the state for display purposes
+++
What would such a transformation be?
Any other way to get this done with no rule?