Again thanks for the help. Please find below the final plan44 script by which sensor values can be transfered from digitalSTROM to plan44. I am putting it online, as accessing the digitalSTROM values might be of interest in my more advanced programs. Nobody seemed to have an idea on how to access them though.
/*********************************************************/
/* Import digitalSTROM sensor values into plan44 */
/*********************************************************/
/* To retrive information from digitalSTROM we proceed as follows */
/* (a) Access the digitalSTROM-Server through the JSON API */
/* Details on getting access to digitalSTROM are in "digitalSTROM System Interfaces" manual v1.7, chapter 6.*/
/* Towards this end one first needs a permanent token that one can get as per the instruction in the manual */
/* The permanent token is then used to retrieve a session token by the command */
/* https://[dssip]/json/system/loginApplication?loginToken=[my permanent token] */
/* Subsequently one can use this session token to perform JSON API calls. */
/* The digitalSTROM JSON nomenclauture has been described in the manual “digitalSTROM-Server JSON”. */
/* To retrive the sensor values from digitalSTROM on can use the following command */
/* HTTP GET /json/apartment/getSensorValues */
/* This translates into a command of the form */
/* https://[dssip]:8080/json/zone/getSensorValues?id=[room_id]&groupID=1&token=[session token] */
/* where the [ ] are placeholders for the ServerIP, the dS room number and the token. */
/* (b) The JSON API is then called within the p44Script and made known to plan44 */
/* The definitions of the Plan44-scriptlangue can be found at: http://[ip_adress_Plan44]/script_ref.html */
Below I paste the plan44 script and the two scripts needed
The Device Init Message
{
'message': 'init',
'protocol': 'simple',
'group': 8, /* Joker */
'name': 'DSS-Import_Sensorvalues2', /* Initialer Name */
'sensors':[
/* S0*/ {"sensortype":1, "usage":1, "group":0, "hardwarename": "temperature", "min":0, "max":100, "resolution":0.1, "updateinterval":120, "alivesigninterval":300},
/* S1 */ {"sensortype":2, "usage":1, "group":0, "hardwarename": "humidity", "min":0, "max":100, "resolution":1, "updateinterval":120, "alivesigninterval":300}]
}
Device implementation:
function updateSensors()
{
/* Get session token. Please note a session token is valid for only 180 seconds */
/* Note the "!" before the URL, this disables certificate checking */
var resACCESS = json(geturl(format('!https://%s:8080/json/system/loginApplication?loginToken=%s', dssip, logintoken)));
var token = resACCESS .result.token;
log (7, "DSS-Import_Sensorvalues Access Token reply = %s", resACCESS)
/* Retrive the sensor values from digitalSTROM with the help of the session token */
var resJSON = json(geturl(format('!https://%s:8080/json/zone/getSensorValues?id=%s&groupID=1&token=%s', dssip, room_id , token)));
log (6, " DSS-Import_Sensorvalues Access JSON reply = %s", resJSON)
var temp = resJSON.result.values[0].TemperatureValue;
var humidity= resJSON.result.values[1].HumidityValue;
/* Forward the retrived values to plan44 by means of the message command */
/* See https://plan44.ch/p44-techdocs/customdevices/#message-format-uber-tcpip */
if (isvalid(temp)) { message(format("S0=%.1f", temp)) }
if (isvalid(humidity)) { message(format("S1=%.1f", humidity)) }
}
/* Main program */
var logintoken = ' HERE COMES THE SECRET PERMANENT TOKEN'; /* [my permanent token] */
var dssip = '192.168.178.21'; /* digitalstrom IP-Adress */
var room_id = '17'; /* Room number as defined in digitalStrom */
/* Call the sequence every 120 seconds */
on (every(120)) { updateSensors() }
return true