I’m been playing with this binding, and am seeing some strange behavior. When I run the rule after a OH reboot, the response is NULL. If I run the rule again after that, it seems to work…sort of. It seems the rule returns data from the last run. An example:
A response from yesterday test run:
2023-05-30 15:13:02.579 [INFO ] [org.openhab.core.model.script.chatgpt ] - Morning message ran: Remember that life is full of changes, and just like the weather, some moments may be hot and others may be cool. But every moment is a new opportunity to shine and overcome any challenge that comes your way. Speaking of weather, in [City State], the temperature is currently a warm 82.292 °F. Over the next 6 hours, the temperature is forecasted to decrease to a high of 75.344 °F and a low of 71.87 °F. So, stay ready for any changes and always remember to make the best out of every moment!
And then the same rule ran this morning (note the temperatures are incorrect / the same as yesterday):
2023-05-31 09:25:02.331 [INFO ] [org.openhab.core.model.script.chatgpt ] - Morning message ran: Remember that no matter what the weather may bring, you have the power to conquer any challenge and rise above it! Keep pushing forward and pursuing your dreams. Speaking of weather, in [City State], it’s currently a wonderful 82.292 °F. However, in the next 6 hours, it will fluctuate with a high of 75.344 °F and a low of 71.87 °F. So be sure to dress accordingly and enjoy the day!
It seems to be using data from the previous run. Maybe that’s why it returns NULL after reboot, because there was no previous run? Any ideas?
My thing:
Thing chatgpt:account:1 [apiKey="APIKEY"] {
Channels:
Type chat : morningMessage "Morning Message" [
model="gpt-3.5-turbo",
temperature="1.0",
systemMessage="Provide an inspirational message then read the following weather data:"
]
Type chat : LocalFact "Local Fact" [
model="gpt-3.5-turbo",
temperature="1.5",
systemMessage="Answer briefly, in 2-3 sentences max. Tell me an interesting fact about the following city:"
]
}
And the rule:
rule "Morning message"
when
Time cron "0 25 9 * * *"
//Time cron "0 13 15 * * *"
then
Morning_Message.sendCommand("In [City State] the current temperature is " + Weather_TemperatureF.state + ". In 6 hours it will be a high of: " + localDailyForecastTodayMaxTemperature.state + ", and a low of: " + localDailyForecastTodayMinTemperature.state)
logInfo("chatgpt", "Morning message ran: " + Morning_Message.state)
say(Morning_Message.state,"googletts:enUSWavenetA","chromecast:audiogroup:kitchen")
end
rule "Evening local fact"
when
Time cron "0 10 17 * * *"
//Time cron "0 12 15 * * *"
then
LocalFact.sendCommand("[City State]")
logInfo("chatgpt", "Evening local fact ran: " + LocalFact.state)
say(LocalFact.state,"googletts:enUSWavenetA","chromecast:audiogroup:kitchen")
end