I’m looking to bring some intelligence to my scripts/rules in respect to where the command came from. For example, if I send a command from my phone versus someone else sending it from their phone. I’ve been digging for a few days and I’m not finding any specific function in the rules that would reply with the IP of the client. Any help would be greatly appreciated! Thanks!
There is no such feature. There is no way for your rules to know form which client a command or update came from.
There is Design Pattern: Manual Trigger Detection which shows you how to detect whether a command came from one of your Rules versus one of your clients, but there is no way to distinguish between external clients.
I’m intrigued that there is no way to access this given that the commands are coming through the REST API. I would have figured that the HTTP header would have been dissected somewhere and sent into the Java backend where it could be called back up. I wonder if a simple script could be written to scan the NGINX logs (I have it as my frontend) and look for the most recent REST API call.
Which may be a great approach to implement it. Given this is an open source project, no one has yet wanted or needed a feature like this enough to implement it. I’m sure the ESH project would welcome a PR.
Just a word of caution, it isn’t as simple as checking the IP address of the client. When you are out and about your phone will have what ever random IP your worked provider assigns. Calls made through myopenhab.org will look like they come from localhost. Client identification that works in all situations is actually quite difficult.