Skip to content

Commit

Permalink
Merge pull request #3 from slapers/fix/remap-codes
Browse files Browse the repository at this point in the history
Update of Loxone code + remapping of the weather codes from tomorrow.io
  • Loading branch information
samvdb authored May 29, 2024
2 parents 8d5daef + 9352a39 commit 2579675
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 97 deletions.
132 changes: 59 additions & 73 deletions loxone_codes.go
Original file line number Diff line number Diff line change
@@ -1,77 +1,63 @@
package main

// https://github.com/sarnau/Inside-The-Loxone-Miniserver/blob/master/Code/LoxoneWeather.py
//
// 1 Clear, cloudless sky (Loxone: Wolkenlos)
// 2 Clear, few cirrus (Loxone: Wolkenlos)
// 3 Clear with cirrus (Loxone: Heiter)
// 4 Clear with few low clouds (Loxone: Heiter)
// 5 Clear with few low clouds and few cirrus (Loxone: Heiter)
// 6 Clear with few low clouds and cirrus (Loxone: Heiter)
// 7 Partly cloudy (Loxone: Heiter)
// 8 Partly cloudy and few cirrus (Loxone: Heiter)
// 9 Partly cloudy and cirrus (Loxone: Wolkig)
//
// 10 Mixed with some thunderstorm clouds possible (Loxone: Wolkig)
// 11 Mixed with few cirrus with some thunderstorm clouds possible (Loxone: Wolkig)
// 12 Mixed with cirrus and some thunderstorm clouds possible (Loxone: Wolkig)
// 13 Clear but hazy (Loxone: Wolkenlos)
// 14 Clear but hazy with few cirrus (Loxone: Heiter)
// 15 Clear but hazy with cirrus (Loxone: Heiter)
// 16 Fog/low stratus clouds (Loxone: Nebel)
// 17 Fog/low stratus clouds with few cirrus (Loxone: Nebel)
// 18 Fog/low stratus clouds with cirrus (Loxone: Nebel)
// 19 Mostly cloudy (Loxone: Stark bewölkt)
// 20 Mostly cloudy and few cirrus (Loxone: Stark bewölkt)
// 21 Mostly cloudy and cirrus (Loxone: Stark bewölkt)
// 22 Overcast (Loxone: Bedeckt)
// 23 Overcast with rain (Loxone: Regen)
// 24 Overcast with snow (Loxone: Schneefall)
// 25 Overcast with heavy rain (Loxone: Starker Regen)
// 26 Overcast with heavy snow (Loxone: Starker Schneefall)
// 27 Rain, thunderstorms likely (Loxone: Kräftiges Gewitter)
// 28 Light rain, thunderstorms likely (Loxone: Gewitter)
// 29 Storm with heavy snow (Loxone: Starker Schneeschauer)
// 30 Heavy rain, thunderstorms likely (Loxone: Kräftiges Gewitter)
// 31 Mixed with showers (Loxone: Leichter Regenschauer)
// 32 Mixed with snow showers (Loxone: Leichter Schneeschauer)
// 33 Overcast with light rain (Loxone: Leichter Regen)
// 34 Overcast with light snow (Loxone: Leichter Schneeschauer)
// 35 Overcast with mixture of snow and rain (Loxone: Schneeregen)
// https://www.loxone.com/enen/kb/weather-service/

// 1 = Clear
// 2 = Bright
// 3 = Cloudy
// 4 = Very cloudy
// 5 = Overcast
// 6 = Fog
// 7 = Low Fog
// 8 = Not used
// 9 = Not used
// 10 = Light rain
// 11 = Rain
// 12 = Heavy rain
// 13 = Drizzle
// 14 = Light freezing rain
// 15 = Heavy freezing rain
// 16 = Light rain showers
// 17 = Heavy rain showers
// 18 = Thunderstorm
// 19 = Heavy thunderstorm
// 20 = Light snow
// 21 = Snow
// 22 = Heavy snow
// 23 = Light snow showers
// 24 = Strong snow showers
// 25 = Light sleet
// 26 = Sleet
// 27 = Heavy sleet
// 28 = Light sleet showers
// 29 = Heavy sleet showers

const (
ClearSky = 1
ClearFewCirrus = 2
ClearWithCirrus = 3
ClearWithFewLowClouds = 4
ClearWithFewLowCloudsAndFewCirrus = 5
ClearWithFewLowCloudsAndCirrus = 6
PartlyCloudy = 7
PartlyCloudyAndFewCirrus = 8
PartlyCloudyAndCirrus = 9
MixedWithSomeThunderstormClouds = 10
MixedWithFewCirrusAndThunderstorm = 11
MixedWithCirrusAndThunderstorm = 12
ClearButHazy = 13
ClearButHazyWithFewCirrus = 14
ClearButHazyWithCirrus = 15
FogLowStratusClouds = 16
FogLowStratusCloudsWithFewCirrus = 17
FogLowStratusCloudsWithCirrus = 18
MostlyCloudy = 19
MostlyCloudyAndFewCirrus = 20
MostlyCloudyAndCirrus = 21
Overcast = 22
OvercastWithRain = 23
OvercastWithSnow = 24
OvercastWithHeavyRain = 25
OvercastWithHeavySnow = 26
RainThunderstormsLikely = 27
LightRainThunderstormsLikely = 28
StormWithHeavySnow = 29
HeavyRainThunderstormsLikely = 30
MixedWithShowers = 31
MixedWithSnowShowers = 32
OvercastWithLightRain = 33
OvercastWithLightSnow = 34
OvercastWithMixtureOfSnowAndRain = 35
Clear = 1
Bright = 2
Cloudy = 3
VeryCloudy = 4
Overcast = 5
Fog = 6
LowFog = 7
LightRain = 10
Rain = 11
HeavyRain = 12
Drizzle = 13
LightFreezingRain = 14
HeavyFreezingRain = 15
LightRainShowers = 16
HeavyRainShowers = 17
Thunderstorm = 18
HeavyThunderstorm = 19
LightSnow = 20
Snow = 21
HeavySnow = 22
LightSnowShowers = 23
StrongSnowShowers = 24
LightSleet = 25
Sleet = 26
HeavySleet = 27
LightSleetShowers = 28
HeavySleetShowers = 29
)
48 changes: 24 additions & 24 deletions tomorrow_icons.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,57 +28,57 @@ package main

func getWeatherCondition(code int) int {

icon := ClearSky
icon := Clear

switch code {
case 0:
icon = 0
case 1000:
icon = ClearSky
icon = Clear
case 1100:
icon = ClearFewCirrus
icon = Bright
case 1101:
icon = PartlyCloudy
icon = Cloudy
case 1102:
icon = MostlyCloudy
icon = VeryCloudy
case 1001:
icon = Overcast
case 2000:
icon = FogLowStratusClouds
icon = Fog
case 2100:
icon = FogLowStratusCloudsWithFewCirrus
icon = LowFog
case 4000:
icon = OvercastWithRain
icon = Drizzle
case 4001:
icon = OvercastWithRain
icon = Rain
case 4200:
icon = OvercastWithLightRain
icon = LightRain
case 4201:
icon = OvercastWithHeavyRain
icon = HeavyRain
case 5000:
icon = OvercastWithSnow
icon = HeavySnow
case 5001:
icon = OvercastWithMixtureOfSnowAndRain
icon = LightSnow
case 5100:
icon = OvercastWithLightSnow
icon = Snow
case 5101:
icon = OvercastWithHeavySnow
// checked above
icon = StrongSnowShowers
case 6000:
icon = OvercastWithMixtureOfSnowAndRain
icon = LightFreezingRain
case 6001:
icon = OvercastWithMixtureOfSnowAndRain
icon = HeavyFreezingRain
case 6200:
icon = OvercastWithMixtureOfSnowAndRain
icon = LightFreezingRain
case 6201:
icon = MixedWithSnowShowers
icon = HeavyFreezingRain
case 7000:
icon = OvercastWithMixtureOfSnowAndRain
icon = Sleet
case 7101:
icon = OvercastWithMixtureOfSnowAndRain
icon = HeavySleet
case 7102:
icon = OvercastWithMixtureOfSnowAndRain
icon = LightSleet
case 8000:
icon = HeavyRainThunderstormsLikely
icon = Thunderstorm
default:
icon = 0
}
Expand Down

0 comments on commit 2579675

Please sign in to comment.