Is it possible to use the ID's of channels and sensors as placeholders in a python script, save them in a value and then compare those values in the script?
If it is, what are the placeholders for the channel and sensor ID so that I can use those in a script?
Unfortunately, those placeholders are not available, but you can run API calls in the script to get live data from specified sensors. You can find a manual for those calls in "Setup > API > Live Data".
Please let me know, if that fits your requirements.
thanks for the reply. Too bad the placeholders do not exist, I had hoped to use those to make the script dynamic and maybe save it in a device template.
Hardcoding the API link means making a different script for every single device or changing the API url whenever the script needs to run on a different device.
Is there no way to dynamically get sensor/channel ID's into a python script? This would also be great in relation to templates/Auto-Discovery.
You can use the set placeholders in the corresponding API calls to make it more dynamic.
You can find a list of placeholders in this KB post.
The placeholders you linked are unfortunately not what I am looking for. Since I want to use the script in a template it will need more work than just getting a sensor OID. I need to compare the sensors names that are in the template or something.
I think I need to go through the API and look at the sensors listed under the device that was just configured through auto-discovery and get the sensors with specific names and their corresponding OIDs. I could then concatenate those sensor IDs to the API request and get the live data I need.
Please let us know, if you need further information.
I do not need more information, as I have decided to leave the Python script as it is. I will document it for later use, it might be interesting for other applications.