Hi everyone,
i have a problem with configuration of new widget.
This widget bring data from item that contain hour/temperature.
The format of item is:
{“00”: 18, “01”: 18, “02”: 17, “03”: 17, “04”: 17, “05”: 16, “06”: 19, “07”: 20, “08”: 21, “09”: 22, “10”: 22, “11”: 22, “12”: 22, “13”: 21, “14”: 20, “15”: 20, “16”: 20, “17”: 21, “18”: 22, “19”: 21, “20”: 20, “21”: 19, “22”: 18, “23”: 18}
The code of widget is:
uid: widget_thermostat_schedule
tags: []
props:
parameters:
- context: item
description: "Inserisci l'Item JSON (es: TermostatoCucina)"
label: Item JSON della stanza
name: roomItem
required: true
type: TEXT
timestamp: Nov 18, 2024, 7:55:27 PM
component: f7-card
config:
title: Programmazione Termostato
class:
- padding
slots:
default:
# REPEATER per creare gli slider orari
- component: oh-repeater
config:
sourceType: range
for: hour
rangeStart: 0
rangeStop: 23
slots:
default:
- component: f7-row
slots:
default:
# Label per l'ora (es. 08:00)
- component: Label
config:
text: =`${('0' + loop.hour).slice(-2)}:00`
# Slider per impostare la temperatura
- component: oh-slider
config:
label: Temperatura
min: 15
max: 25
step: 1
scale: true
scaleSteps: 10
scaleSubSteps: 1
# Valore iniziale: leggiamo dalla mappa interna
value: >
(() => {
try {
const hourKey = ('0' + loop.hour).slice(-2);
console.log("Valore corrente per ora", hourKey, ":", thermostatState[hourKey]);
return thermostatState[hourKey] !== undefined ? thermostatState[hourKey] : 15;
} catch (error) {
console.error("Errore durante la lettura dello stato:", error);
return 15;
}
})()
# Aggiorna la mappa interna
onChange: >
(event) => {
try {
const hourKey = ('0' + loop.hour).slice(-2);
thermostatState[hourKey] = event.detail.value; // Aggiorna la mappa
console.log("Nuovo stato per", hourKey, ":", thermostatState);
} catch (error) {
console.error("Errore durante l'aggiornamento:", error);
}
}
# PULSANTE per salvare il JSON
- component: f7-button
config:
text: "Salva Programmazione"
onClick: >
() => {
try {
const jsonString = JSON.stringify(thermostatState);
console.log("JSON inviato:", jsonString);
items[props.roomItem].sendCommand(jsonString);
} catch (error) {
console.error("Errore durante l'invio del JSON:", error);
}
}
But sliders not work, they are always on “15” value and the props is configure correctly.
Can you help me?