Dear all
I ask again your help
I have the following json file as output from a thermovalve,
{
"auto_lock": "MANUAL",
"away_mode": "OFF",
"away_preset_days": 5,
"away_preset_temperature": 20,
"battery_low": false,
"boost_time": 300,
"child_lock": "UNLOCKED",
"comfort_temperature": 35,
"current_heating_setpoint": 17,
"eco_temperature": 13,
"force": "normal",
"holidays": [
{
"hour": 6,
"minute": 0,
"temperature": 20
},
{
"hour": 8,
"minute": 0,
"temperature": 15
},
{
"hour": 11,
"minute": 30,
"temperature": 15
},
{
"hour": 12,
"minute": 30,
"temperature": 15
},
{
"hour": 17,
"minute": 30,
"temperature": 20
},
{
"hour": 22,
"minute": 0,
"temperature": 15
}
],
"last_seen": "2020-12-31T08:45:53.953Z",
"linkquality": 135,
"local_temperature": 22,
"local_temperature_calibration": 2,
"max_temperature": 35,
"min_temperature": 5,
"position": 0,
"preset": "manual",
"system_mode": "auto",
"week": "5+2",
"window_detection": "OFF",
"window_detection_params": {
"minutes": 17,
"temperature": 2
},
"workdays": [
{
"hour": 6,
"minute": 15,
"temperature": 18
},
{
"hour": 8,
"minute": 15,
"temperature": 17
},
{
"hour": 11,
"minute": 45,
"temperature": 17
},
{
"hour": 13,
"minute": 15,
"temperature": 17
},
{
"hour": 18,
"minute": 15,
"temperature": 18
},
{
"hour": 22,
"minute": 15,
"temperature": 17
}
]
}
for single properties there is no problem, i retrieve setting using JSONPATH and publish it with formatBeforePublish
Type string : auto_lock [ stateTopic="zigbee2mqtt/Termovalvola_Test1", transformationPattern="JSONPATH:$.auto_lock", commandTopic="zigbee2mqtt/Termovalvola_Test1/set", formatBeforePublish="{\"auto_lock\" : \"%s\"}" ]
the problem is for the holydays or workdays properties;
there are 6 period for and i need to change it separately:
"holidays": [
{
"hour": 6,
"minute": 0,
"temperature": 20
},
{
"hour": 8,
"minute": 0,
"temperature": 15
},
{
"hour": 11,
"minute": 30,
"temperature": 15
},
{
"hour": 12,
"minute": 30,
"temperature": 15
},
{
"hour": 17,
"minute": 30,
"temperature": 20
},
{
"hour": 22,
"minute": 0,
"temperature": 15
}
],
what I need is to 2 items for each period :
workdays_time_period1 (and need to retrieve 6:00 considering the first period as example)
workdays_temp_period1 (need to retrieve 20)
and the same for all the periords and the question is how can I do this?
and when items changes I need to publish them trasforming time in two parts, hours and minute and publish the entire string for all periods, i done it with a rule declaring tre items for each period
val mqttActions = getActions("mqtt","mqtt:broker:mosquitto")
var jsonString = "{\"holidays\":["
jsonString = jsonString + "{\"hour\":" + Termovalvola_Test1_H1h_Config.state +",\"minute\":" + Termovalvola_Test1_H1m_Config.state + ",\"temperature\":" + Termovalvola_Test1_H1T_Config.state +"},"
jsonString = jsonString + "{\"hour\":" + Termovalvola_Test1_H2h_Config.state +",\"minute\":" + Termovalvola_Test1_H2m_Config.state + ",\"temperature\":" + Termovalvola_Test1_H2T_Config.state +"},"
jsonString = jsonString + "{\"hour\":" + Termovalvola_Test1_H3h_Config.state +",\"minute\":" + Termovalvola_Test1_H3m_Config.state + ",\"temperature\":" + Termovalvola_Test1_H3T_Config.state +"},"
jsonString = jsonString + "{\"hour\":" + Termovalvola_Test1_H4h_Config.state +",\"minute\":" + Termovalvola_Test1_H4m_Config.state + ",\"temperature\":" + Termovalvola_Test1_H4T_Config.state +"},"
jsonString = jsonString + "{\"hour\":" + Termovalvola_Test1_H5h_Config.state +",\"minute\":" + Termovalvola_Test1_H5m_Config.state + ",\"temperature\":" + Termovalvola_Test1_H5T_Config.state +"},"
jsonString = jsonString + "{\"hour\":" + Termovalvola_Test1_H6h_Config.state +",\"minute\":" + Termovalvola_Test1_H6m_Config.state + ",\"temperature\":" + Termovalvola_Test1_H6T_Config.state +"}"
jsonString = jsonString + "]}"
mqttActions.publishMQTT("zigbee2mqtt/Termovalvola_Test1/set/schedule",jsonString)
but I hope there is a more simple way to do it and the question is what is the simple way?
other question concern the best way to represent the input field for time in main UI,
i use an input item declaring it as time and it works
- component: oh-input-item
config:
label: Orario
type: time
item: =props.timeItem
color: orange
outline: true
validate: true
variable: alarm
but after i need to split hour and minute to format the json string to publish.
thanks in advance for your help