sipvoip
(Nathan Stratton)
November 28, 2024, 4:20pm
21
Any idea how to update this for OpenHab 4?
rule "Set Z-Wave Clocks"
when
Time cron "30 59 23 * * ?"
then
logInfo("Z-Wave","Setting Z-Wave Clocks")
Clock?.members.forEach[ DateTime clock |
clock.sendCommand(ON)
]
end
2024-11-28 11:17:51.943 [INFO ] [org.openhab.core.model.script.Z-Wave] - Setting Z-Wave Clocks
2024-11-28 11:17:51.945 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'clock-1' failed: 'sendCommand' is not a member of 'DateTime'; line 7, column 7, length 21 in clock
sipvoip
(Nathan Stratton)
November 28, 2024, 4:46pm
22
Wow, ChatGPT 01-preview rocks! It took it a few times, but got it:
import java.time.format.DateTimeFormatter
rule "Set Z-Wave Clocks"
when
Time cron "30 59 23 * * ?"
then
logInfo("Z-Wave", "Setting Z-Wave Clocks")
Clock?.members.forEach[ clock |
val formattedDate = now.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
logInfo("Z-Wave", "Updating clock: " + clock.name + " with time: " + formattedDate)
clock.postUpdate(formattedDate)
]
end
2024-11-28 11:43:01.929 [INFO ] [org.openhab.core.model.script.Z-Wave] - Setting Z-Wave Clocks
2024-11-28 11:43:01.931 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Mom_Bedroom_Tstat_Clock with time: 2024-11-28T11:43:01.930645711-05:00
2024-11-28 11:43:01.932 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Apartment_Tstat_Clock with time: 2024-11-28T11:43:01.932415443-05:00
2024-11-28 11:43:01.934 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Great_Room_Tstat_Clock with time: 2024-11-28T11:43:01.934104508-05:00
2024-11-28 11:43:01.936 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Master_Bedroom_Tstat_Clock with time: 2024-11-28T11:43:01.935739036-05:00
2024-11-28 11:43:01.938 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Guest_Bedroom_Tstat_Clock with time: 2024-11-28T11:43:01.937604045-05:00
2024-11-28 11:43:01.939 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Datacenter_Tstat_Clock with time: 2024-11-28T11:43:01.939135037-05:00
2024-11-28 11:43:01.941 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Office_Tstat_Clock with time: 2024-11-28T11:43:01.940670048-05:00
2024-11-28 11:43:01.946 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Shop_Tstat_Clock with time: 2024-11-28T11:43:01.9462315-05:00
2024-11-28 11:43:01.948 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Garage_Tstat_Clock with time: 2024-11-28T11:43:01.947951473-05:00
2024-11-28 11:43:01.952 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Kitchen_Tstat_Clock with time: 2024-11-28T11:43:01.951598713-05:00
2024-11-28 11:43:01.953 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Dad_Bedroom_Tstat_Clock with time: 2024-11-28T11:43:01.953203445-05:00
2024-11-28 11:43:01.955 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Electric_Room_Tstat_Clock with time: 2024-11-28T11:43:01.955145009-05:00
2024-11-28 11:43:01.957 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Second_Floor_Tstat_Clock with time: 2024-11-28T11:43:01.957157147-05:00
2024-11-28 11:43:01.959 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Basement_Tstat_Clock with time: 2024-11-28T11:43:01.958861527-05:00
2024-11-28 11:43:01.961 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Water_Room_Tstat_Clock with time: 2024-11-28T11:43:01.96050737-05:00
2024-11-28 11:43:01.970 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: First_Floor_Tstat_Clock with time: 2024-11-28T11:43:01.96918701-05:00
2024-11-28 11:43:01.971 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Joshua_Bedroom_Tstat_Clock with time: 2024-11-28T11:43:01.97138272-05:00
2024-11-28 11:43:01.973 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Breezeway_Tstat_Clock with time: 2024-11-28T11:43:01.97288649-05:00
2024-11-28 11:43:01.974 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Basement_Storage_Tstat_Clock with time: 2024-11-28T11:43:01.974371279-05:00
2024-11-28 11:43:01.976 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Emma_Bedroom_Tstat_Clock with time: 2024-11-28T11:43:01.976004511-05:00
2024-11-28 11:43:01.986 [INFO ] [org.openhab.core.model.script.Z-Wave] - Updating clock: Living_Room_Tstat_Clock with time: 2024-11-28T11:43:01.985227074-05:00
Yes, I have a bunch of thermostats…