Identifying (and exploiting) UI client IP/MAC

I have set up Things and linked Items, which allow to identify whether a certain device is linked to the same WIFI network to which using the Network binding like so:

Thing

UID: network:pingdevice:__0
label: User0
thingTypeUID: network:pingdevice
configuration:
  hostname: 192.168.x.x
  macAddress: XX:YY:22:BB:AA:99
  refreshInterval: 60000
  retry: 1
  timeout: 5000
channels:
  - id: online
    channelTypeUID: network:online
    label: Online
    description: States whether a device is online or offline
    configuration: {}
  - id: latency
    channelTypeUID: network:latency
    label: Latency
    description: States the latency time
    configuration: {}
  - id: lastseen
    channelTypeUID: network:lastseen
    label: Last Seen
    description: States the last seen date/time
    configuration: {}

Item:

Switch _User_Admin0 "namehere" <"iconify:mdi:alpha-d-box-outline"> (_Users,_Household, _IsHome, _Trusted, _IsGuarded) ["Status","Presence","Admin"] {channel="network:pingdevice:__0:online",widgetOrder="10",listWidget="oh-label-item" [visible="=items._User_Admin0.state=='ON'", badge="Here"]}

This (more or less) works for basic presence detection of individual users. I have set my wifi router DHCP settings such that they reassign a pseudo-static IP address upon each connection.

Now, I’m wondering the following: Can one get this IP (or MAC) address of the client device that is connecting to MainUI and use this inside (custom) widgets to (identify who is using openHAB) and adapt some widget settings (custom visibibility settings, language choice, or custom widget-order come to mind)…

I have no clue, how I would query from within a widget the devices ip address… Any advise?

This is outside the capabilities of the custom widgets.

However, if you give your users their own UI accounts there is a user object in the widget expressions that gives you the id of the logged in user (and any roles that user has been assigned to).

Cheers Justin – I’ll work with the user object.

Just one additional question. is it possible to require/include/import (or what not) that same (user) object also in a script/rule?

Not really, no. The UI and the main OH instance exist in two very different contexts because one OH instance can have multiple different UIs connected to it at any one time. If you have two different users logged in to the MainUI on two different devices, how is the rule on the single OH instance supposed to know which user to use when it runs?

The one caveat to this is that, as along as there is user interaction (i.e., the user clicks a button or a link) then you can send the user information from that UI instance to a rule using the rule action and the actionRuleContext property.