Hi Juankar,
Even though this is a somewhat older post, I still have an answer.
The options field consists of a chain of keyword=value pairs, separated by ';'. For example, for a selector switch you will find the following content in the DeviceStatus table, options column:
Code: Select all
LevelActions:fHx8;LevelNames:T2ZmfERpc2NoYXJnZXxDaGVja3xDaGFyZ2U=;LevelOffHidden:ZmFsc2U=;SelectorStyle:MA==
The keys are readable but the values are not. That's because the values are b64 encoded.
the good news is that I wrote two small tools to read the option field and write it back:
- getoptions.py -i <idx> retrieves the options field from the specified index and leaves it in the file: data.json
- setoption.py reads the file, constructs the optionsfield and writes it back to the database. No parameter is needed because the IDX is stated in the file.
so, after ./getoptions.py -i 1987 de contents of data.json is:
Code: Select all
{
"id": 1987,
"name": "WWH-living-room-heater-state",
"options": {
"LevelActions": "|||",
"LevelNames": "Off|Discharge|Check|Charge",
"LevelOffHidden": "false",
"SelectorStyle": "0"
}
}
You can edit this file with nano or vi: adjust, add keywords and values, etc. As an example, I add a keyword 'watchdogminutes' with value 15: this device must be updated at least every 15 minutes.
Code: Select all
{
"id": 1987,
"name": "WWH-living-room-heater-state",
"options": {
"LevelActions": "|||",
"LevelNames": "Off|Discharge|Check|Charge",
"LevelOffHidden": "false",
"watchdogminutes": "15",
"SelectorStyle": "0"
}
}
After ./setoptions.py the data is written back. (yes, you are allowed to change the idx. And no, the name field is never written back)
The strong point of the option field is that all keyword=value pairs placed here will also be mentioned in MQTT messages (domoticz/out). An external process subscribed to 'domoticz/out' can now take care of this. If the status of the device changes, this is the corresponding MQTT message:
MQTT:
Code: Select all
{
"Battery" : 255,
"LastUpdate" : "2023-10-10 15:40:16",
"LevelActions" : "|||",
"LevelNames" : "Off|Discharge|Check|Charge",
"LevelOffHidden" : "false",
"RSSI" : 12,
"SelectorStyle" : "0",
"description" : "",
"dtype" : "Light/Switch",
"hwid" : "2",
"id" : "00014813",
"idx" : 1987,
"name" : "WWH-living-room-heater-state",
"nvalue" : 0,
"stype" : "Selector Switch",
"svalue1" : "0",
"switchType" : "Selector",
"unit" : 1,
"watchdogminutes" : "15"
}
be my guest and use the little tools. A small word of warning: managing the database is called 'a back door to domoticz' and should be avoided when possible...
kind regards and good luck, --Edgar