I threw this at Copilot and received an actual answer.
It appears to be knowledgeable of things like ESP EASY rules.
Within ESP EASY rules, convert 24 hour time to 12 hour time
Certainly! In ESP Easy, you can use rules to convert 24-hour time format to 12-hour time format. Here's an example of how you can achieve this using rules in ESP Easy.
You will need to use some basic arithmetic and conditional logic to handle the conversion. Below is a sample rule script that demonstrates the conversion process:
rules
on System#Boot do
timerSet,1,10 // Set a timer to update the time every 10 seconds
endon
on Rules#Timer=1 do
// Get the current hour and minute
Let,1,%sysyear%
Let,2,%sysmonth%
Let,3,%sysday%
Let,4,%syshour%
Let,5,%sysminute%
// Convert 24-hour time to 12-hour format
If [var#4] > 12
Let,6,[var#4]-12
Let,7,PM
Else
If [var#4] = 0
Let,6,12
Else
Let,6,[var#4]
EndIf
Let,7,AM
EndIf
// Format the time as hh:mm AM/PM
Let,8,[var#6]
Let,9,[var#5]
Let,10,[var#8]:[var#9] [var#7]
// Output the formatted time
Publish,device/time,[var#10]
// Restart the timer
timerSet,1,10
endon
In this example:
The current hour (%syshour%) is checked.
If the hour is greater than 12, it subtracts 12 to convert it to 12-hour format and sets the period to PM.
If the hour is 0, it sets the hour to 12 and the period to AM.
It formats the time and publishes it to a topic called device/time.
This is just one way to handle the conversion using ESP Easy rules. Feel free to customize it based on your specific needs!
Use Copilot (Chat GTP?) to help writing rules
Moderators: grovkillen, Stuntteam, TD-er
Re: Use Copilot (Chat GTP?) to help writing rules
Nice, however it will not work like this as we don't yet support string formatting to be stored in variables.
But with some minor changes, it can be made to work like this.
You could also use one of the many system variables with "_am" in the variable name as shown on the system variables page...
But with some minor changes, it can be made to work like this.
You could also use one of the many system variables with "_am" in the variable name as shown on the system variables page...
Code: Select all
%lcltime% 2025-01-08 06:48:38
%lcltime_am% 2025-01-08 6:48:38 AM
%systm_hm% 6:48
%systm_hm_0% 06:48
%systm_hm_sp% 6:48
%systm_hm_am% 6:48 AM
%systm_hm_am_0% 06:48 AM
%systm_hm_am_sp% 6:48 AM
%systime% 06:48:38
%systime_am% 6:48:38 AM
%systime_am_0% 06:48:38 AM
%systime_am_sp% 6:48:38 AM
Re: Use Copilot (Chat GTP?) to help writing rules
Wow. I asked copilot to create an ESPEasy rule to display DS18B20 temp on an LCD and the results were believable.
The AI overlords are going to replace us all. I just hope they keep me as a pet.
- Thomas
The AI overlords are going to replace us all. I just hope they keep me as a pet.
- Thomas
Re: Use Copilot (Chat GTP?) to help writing rules
I'll be truly impressed when ChatGTP will fix the Espressif WiFi code.
Who is online
Users browsing this forum: No registered users and 12 guests