a.tibi
(Ahmad Yazan Tibi)
July 18, 2018, 5:49pm
1
Dear Community,
I want to make settings files for my home automation, so the system can read it and populate its values to system variables (items),
Therefore, I would like to take your advises for couple of questions:
What is best practice to use for saving settings, a set of Items, or (global) variables ?
What is the recommended settings file, I am thinking to make it xml file, (I am listing just raw file to clear the idea):
<HABSettings>
<RGBW>
<MaxDim>90</MaxDim>
<DimPeriod>20</DimPeriod>
<DayColor>205<DayColor>
<AfternoonColor>58</AfternoonColor>
<NightColor>160</NightColor>
</RGBW>
<AC>
<DayTemp>22</DayTemp>
<NightTemp>24</NightTemp>
</AC>
<Light>
<EveningDim>70</EveningDim>
<NightDim>20</NightDim>
</Light>
</HABSettings>
5iver
(Scott Rushworth)
July 18, 2018, 6:38pm
2
Have you considered just using a HashMap in your rule file?
val HashMap<String,HashMap<String,Integer>> HABSettings = newHashMap(
"RGBW" -> (newHashMap(
"MaxDim" -> 90,
"DimPeriod" -> 20,
"DayColor" -> 205,
"AfternoonColor" -> 58,
"NightColor" -> 160)
),
"AC" -> (newHashMap(
"DayTemmp" -> 90,
"NightTemp" -> 20)
),
"Light" -> (newHashMap(
"EveningDim" -> 90,
"NightDim" -> 20)
)
)
Then access it with…
HABSettings.get("RGBW").get("MaxDim")
You can programmatically change values, but the hardcoded values will reset after a restart or rule file save.
HABSettings.put("RGBW").put("MaxDim")
If you want to use files, there was a recent tutorial on using configuration files with JSR223 w/ the lucid modules .
I also had a recent discussion about this with @rlkoshak and was playing around with some examples .
rlkoshak
(Rich Koshak)
July 18, 2018, 7:10pm
3
To summarize the link Scott provided, your options are:
3 Likes