NightMan-1 / netatmo-munin-go

Display NetAtmo data at Munin graphs
MIT License
2 stars 0 forks source link

Feature Request #1

Closed Shizzlebix closed 6 years ago

Shizzlebix commented 7 years ago

Hello,

first THANK you for this plugin.

Now i have a question. So i have 2 more sensors in house and outdoor a wind and a rain sensor. Is there a way to build this also in this great tool, so i can draw it with munin?

NightMan-1 commented 7 years ago

Hello!

Sorry, i not have this modules and can not test it, please compile example app from here - https://github.com/exzz/netatmo-api-go - and post full output here, and i will try add more sensors..

Shizzlebix commented 7 years ago

okay thank you i will test it. if it helps.

Station : Pleasure Dome Module : Outdoor Temperature : %!s(float32=12.8) (1507874192) Humidity : %!s(int32=76) (1507874192) LastMesure : %!s(int64=1507874192) (1507874192) Module : Niederschlagsmesser Rain1Day : %!s(float32=0) (1507874205) LastMesure : %!s(int64=1507874205) (1507874205) Rain : %!s(float32=0) (1507874205) Rain1Hour : %!s(float32=0) (1507874205) Module : Indoor 1 Humidity : %!s(int32=71) (1507874198) CO2 : %!s(int32=1288) (1507874198) LastMesure : %!s(int64=1507874198) (1507874198) Temperature : %!s(float32=19.4) (1507874198) Module : Windmesser LastMesure : %!s(int64=1507874109) (1507874109) WindAngle : %!s(int32=28) (1507874109) WindStrength : %!s(int32=1) (1507874109) GustAngle : %!s(int32=28) (1507874109) Module : Indoor Noise : %!s(int32=34) (1507874213) Pressure : %!s(float32=1022.3) (1507874213) AbsolutePressure : %!s(float32=1006) (1507874213) LastMesure : %!s(int64=1507874213) (1507874213) Temperature : %!s(float32=20.8) (1507874213) Humidity : %!s(int32=73) (1507874213) CO2 : %!s(int32=1424) (1507874213)

about more indoor modules is a for or foreach available? so for each ModulName "Indoor*" or so on?

Shizzlebix commented 7 years ago

the second indoor work since i had copy your code to a second one if (module.ModuleName == "Indoor 1"){ _, data := module.Data() for dataType, value := range data { //CO2 info if (len(os.Args) == 2 && os.Args[1] == "-co2" && dataType == "CO2"){ fmt.Printf("co21.value %v\n", value) //Humidity Indor info }else if (len(os.Args) == 2 && os.Args[1] == "-hum" && dataType == "Humidity"){ fmt.Printf("hum_indor1.value %v\n", value) //Temperature Indor info }else if (len(os.Args) == 2 && os.Args[1] == "-temp" && dataType == "Temperature"){ fmt.Printf("temp_indor1.value %v\n", value) } } }

and modify the munin printout....

is it a good idea then in the config is a possibility to set the numbers of indoor sensors an the name of this ones?

about the wind and rain sensors i have no idea to put it in :( so i cant help :(

Shizzlebix commented 7 years ago

For Rain_Sensor i had it: @ help ++ fmt.Println("\t -rain - for Rain info")

@ plugin info ++ if (len(os.Args) == 3 && os.Args[1] == "-rain" && os.Args[2] == "config"){ ++ fmt.Println("graph_title Netatmo Rain level") ++ fmt.Println("graph_vlabel mm") ++ fmt.Println("graph_category netatmo") ++ fmt.Println("rain_rain.label rain") ++ fmt.Println("rain_hour.label lasthour") ++ fmt.Println("rain_day.label lastday") ++ os.Exit(0) ++ }

@ output info ++ if (module.ModuleName == "Niederschlagsmesser"){ ++ _, data := module.Data() ++ for dataType, value := range data { ++ //Rain Rain info ++ if (len(os.Args) == 2 && os.Args[1] == "-rain" && dataType == "Rain"){ ++ fmt.Printf("rain_rain.value %v\n", value) ++ //Rain Last Hour info ++ }else if (len(os.Args) == 2 && os.Args[1] == "-rain" && dataType == "Rain1Hour"){ ++ fmt.Printf("rain_hour.value %v\n", value) ++ //Rain Last Day info ++ }else if (len(os.Args) == 2 && os.Args[1] == "-rain" && dataType == "Rain1Day"){ ++ fmt.Printf("rain_day.value %v\n", value) ++ } ++ } ++ }

-> rain_rain.value 0 rain_hour.value 0 rain_day.value 0

NightMan-1 commented 7 years ago

The new version is almost ready, I will publish it within 1-2 days ... completely redesigned the work logic, now all types of modules and several modules of the same type work fine, I'm testing :)

NightMan-1 commented 7 years ago

Hello!

New version uploaded, for update you must delete all /etc/munin/plugins/netatmo-munin-*.sh files and add only one link to netatmo-munin-plugin executable ... and old munin data will be lost, sorry for this

Shizzlebix commented 7 years ago

Hello,

i will test it as soon as possible. Thank you very much. i found some issues in the api modul so i write the api person about that.

1) there is issue about gustwind (is missing by api) 2) i had add a feature request there about device informations.

https://github.com/romainbureau/netatmo-api-go

in this fork api the wind problem is fixed (fyi)

Shizzlebix commented 7 years ago

missing rain (ondemand) -> Rain : %!s(float32=0) (1507874205) -> fix with: fmt.Printf("rain%v.label %v\n", key, value.name) fmt.Printf("rain%v.value %v\n", key, value.data)

multigraph netatmo_wind missing wind angel -> WindAngle missing wind gust angel -> GustAngle : %!s(int32=28) (1507874109) missing wind gust speed -> bug by api

in V1 i had it do so....

RAIN: if (module.ModuleName == "Niederschlagsmesser"){ _, data := module.Data() for dataType, value := range data { // fmt.Println(dataType, value) //Rain Rain info if (len(os.Args) == 2 && os.Args[1] == "-rain" && dataType == "Rain"){ fmt.Printf("rain_rain.value %v\n", value) //Rain Last Hour info }else if (len(os.Args) == 2 && os.Args[1] == "-rain" && dataType == "Rain1Hour"){ fmt.Printf("rain_hour.value %v\n", value) //Rain Last Day info }else if (len(os.Args) == 2 && os.Args[1] == "-rain" && dataType == "Rain1Day"){ fmt.Printf("rain_day.value %v\n", value) }

Wind: if (module.ModuleName == "Windmesser"){ _, data := module.Data() for dataType, value := range data { // fmt.Println(dataType, value) //Wind Angel info if (len(os.Args) == 2 && os.Args[1] == "-wind" && dataType == "WindAngle"){ fmt.Printf("wind_angel.value %v\n", value) //Wind Strength info }else if (len(os.Args) == 2 && os.Args[1] == "-wind" && dataType == "WindStrength"){ fmt.Printf("wind_strength.value %v\n", value) //Wind GustAngel info }else if (len(os.Args) == 2 && os.Args[1] == "-wind" && dataType == "GustAngle"){ fmt.Printf("wind_gangel.value %v\n", value) //Wind Guststrength info }else if (len(os.Args) == 2 && os.Args[1] == "-wind" && dataType == "GustStrength"){ fmt.Printf("wind_gstrength.value %v\n", value) }

                            }
                    } 
NightMan-1 commented 7 years ago

Hello! New app support rain daily and hourly info: fmt.Printf("raindaily%v.value %v\n", key, value.data) fmt.Printf("rainhourly%v.value %v\n", key, value.data) as i can understand, your rain_rain.value can be only 0 or 1 (true or false), i not sure that we really need graphic for this ...

Wind also supported: fmt.Printf("windspeed%v.label %v (speed)\n", key, value.name) fmt.Printf("windgust%v.label %v (gust)\n", key, value.name)

Wind angle can be 0-360, is it right? We can not make good graphic for this :(

Shizzlebix commented 7 years ago

ah you mean just rain is 0 or 1? okay... no grafic you are right :( just 0 to 360 grad okay :(

NightMan-1 commented 7 years ago

ah you mean just rain is 0 or 1? okay...

it's raining now (1) or not (0) :)

do you have any ideas for this graphs: Wind-Angel Gust-Angel

I think the standard graphics are completely useless for this

Shizzlebix commented 7 years ago

can we use each color for a angel? red = nord green = south as example?

NightMan-1 commented 7 years ago

hm .... can you make example in excel?

Shizzlebix commented 7 years ago

i mean as example this http://2.bp.blogspot.com/_GggamMj9KE4/TEd0knqmxyI/AAAAAAAAB4g/0yQf9ykklqs/s1600/forum_sum-day.png red as north / ....

NightMan-1 commented 7 years ago

it's not possible, we have only one value - wind angle, it can be 0-360, will be only one line on graph, and it's completely useless for wind, i think ...on the graphs we have only in the scale - the time and the value of the measurement, I can not imagine how to display the direction of the wind: ( .... we can do something like this - https://data.soderslattsfk.se/munin/localdomain/localhost.localdomain/wx_wind_direction.html but it's not clear and useless :(

NightMan-1 commented 7 years ago

example for rain_value - https://data.soderslattsfk.se/munin/localdomain/localhost.localdomain/wx_rain.html

NightMan-1 commented 7 years ago

and more rain - https://data.soderslattsfk.se/munin/localdomain/localhost.localdomain/wx_rain_day.html

Shizzlebix commented 7 years ago

oh i was think that it be possible what one scale from 0 to 90 the second from 91 to 180 and so on.... you know? i dont know its work

NightMan-1 commented 7 years ago

New version uploaded:

Test it :)

Shizzlebix commented 7 years ago

i will test it as soon as possible :) thanks

my comment about the api bug have you read?

https://github.com/romainbureau/netatmo-api-go in this fork api the wind problem is fixed (fyi)

NightMan-1 commented 7 years ago

Yes, i read your comment, api fork have a little other data format ... new version uploaded :)

Shizzlebix commented 7 years ago

go get github.com/romainbureau/netatmo-api-go git pull change wind angel to true in netatmo.cfg ./install

/etc/munin/plugins# munin-run netatmo-munin-plugin panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8fd14]

goroutine 1 [running]: panic(0x259e80, 0x1060c010) /usr/lib/go-1.7/src/runtime/panic.go:500 +0x33c github.com/go-ini/ini.(Section).GetKey(0x0, 0x283c34, 0x3, 0x352a38, 0x0, 0x0) /root/go/src/github.com/go-ini/ini/section.go:101 +0x24 github.com/go-ini/ini.(Section).Key(0x0, 0x283c34, 0x3, 0x0) /root/go/src/github.com/go-ini/ini/section.go:160 +0x30 main.main() /root/netatmo-munin-go/netatmo-munin-plugin.go:57 +0x500

NightMan-1 commented 7 years ago

Try compile and run it from console, without "munin-run" ....working?

Shizzlebix commented 7 years ago

/usr/share/munin/plugins/netatmo-munin-plugin panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8fd14]

goroutine 1 [running]: panic(0x259e80, 0x1060c010) /usr/lib/go-1.7/src/runtime/panic.go:500 +0x33c github.com/go-ini/ini.(Section).GetKey(0x0, 0x283c34, 0x3, 0x352a38, 0x0, 0x0) /root/go/src/github.com/go-ini/ini/section.go:101 +0x24 github.com/go-ini/ini.(Section).Key(0x0, 0x283c34, 0x3, 0x0) /root/go/src/github.com/go-ini/ini/section.go:160 +0x30 main.main() /root/netatmo-munin-go/netatmo-munin-plugin.go:57 +0x500

same error

NightMan-1 commented 7 years ago

ok, i understand, please add this to netatmo.cfg:

[sensors] CO2 = true Noise = true Pressure = true Humidity = true Temperature = true WindStrength = true Rain = true WindAngle = false

Shizzlebix commented 7 years ago

you mean in the /etc/munin/netatmo.cfg?

i do... AHH now it works. Nice.....

NightMan-1 commented 7 years ago

yes

Shizzlebix commented 7 years ago

now is seems nice.....

Shizzlebix commented 7 years ago

so the first rain was coming. Netatmo says: last hour 0mm rain / last day 0,1mm rain

munin-plugin say: daily AND hourly 101,00 mm

this are 2 problems i think. first is the 0.1 / 101 and the second that daily and hourly says the same but it is not

Shizzlebix commented 7 years ago

also wind speed and wind gust also have the same data (this is not correct) :(

by rain it is just one value:

multigraph netatmo_rain

{Niederschlagsmesser 16.766} <--- output from println that shows all information. i am sry but i dont know on witch type you read the datas :(

rain_daily_0.value 16.766 rain_hourly_0.value 16.766

NightMan-1 commented 7 years ago

Hello! Sorry, my mistake, data at graphics was really wrong :( Fix uploaded...

Shizzlebix commented 7 years ago

Thanks. i had test it

/usr/share/munin/plugins/netatmo-munin-plugin multigraph netatmo_wind_angl wind_angle_0.value 7 gust_angle_0.value 71

multigraph netatmo_wind wind_speed_0.value 13 panic: runtime error: index out of range

goroutine 1 [running]: panic(0x25ae80, 0x1060c030) /usr/lib/go-1.7/src/runtime/panic.go:500 +0x33c main.main() /root/netatmo-munin-go/netatmo-munin-plugin.go:266 +0x5978

The netatmo.cfg ist correct as i can see

NightMan-1 commented 7 years ago

Try replace line 266 to this code:

if (len(modulesData["guststrength"]) >0){
    fmt.Printf("wind_gust_%v.value %v\n", key, modulesData["guststrength"][key].data)
}
Shizzlebix commented 7 years ago

line 266 is } so i changed:


                         case "windstrength":
                                if (configGlobal.WindStrength) {
                                        fmt.Println("multigraph netatmo_wind")
                                        for key, _ := range m_data {
                                                fmt.Printf("wind_speed_%v.value %v\n", key, modulesData["windstrength"][key].data)
                                                fmt.Printf("wind_gust_%v.value %v\n", key, modulesData["guststrength"][key].data)
                                        }
                                        fmt.Println("")
                                }

to


                        case "windstrength":
                                if (configGlobal.WindStrength) {
                                        fmt.Println("multigraph netatmo_wind")
                                        for key, _ := range m_data {
                                                fmt.Printf("wind_speed_%v.value %v\n", key, modulesData["windstrength"][key].data)
                                                if (len(modulesData["guststrength"]) >0){
                                                fmt.Printf("wind_gust_%v.value %v\n", key, modulesData["guststrength"][key].data)
                                                }
                                        }
                                        fmt.Println("")
                                }
Shizzlebix commented 7 years ago

/usr/share/munin/plugins/netatmo-munin-plugin multigraph netatmo_humidity hum_0.value 76 hum_1.value 70 hum_2.value 71

multigraph netatmo_rain panic: runtime error: index out of range

goroutine 1 [running]: panic(0x259e80, 0x1060c030) /usr/lib/go-1.7/src/runtime/panic.go:500 +0x33c main.main() /root/netatmo-munin-go/netatmo-munin-plugin.go:275 +0x48d4

im not so good as you :(

NightMan-1 commented 7 years ago

sad .... first, we make separate graphics for all data, test and then combine ... 5 min...

NightMan-1 commented 7 years ago

uploaded ...

Shizzlebix commented 7 years ago

this work but i see now another problem :( first run:

multigraph netatmo_temp
temp_0.value 17.7
temp_1.value 19
temp_2.value 19.5
multigraph netatmo_rain_daily
rain_daily_0.value 0.01313
multigraph netatmo_co2
co2_0.value 498
co2_1.value 362
multigraph netatmo_wind_angl
wind_angle_0.value 20
multigraph netatmo_wind_gust_angl
gust_angle_0.value 7
multigraph netatmo_pressure
pressure_0.value 762.96
multigraph netatmo_noise
noise_0.value 34
multigraph netatmo_humidity
hum_0.value 75
hum_1.value 70
hum_2.value 72
multigraph netatmo_wind
wind_speed_0.value 15

second run:

multigraph netatmo_humidity
hum_0.value 75
hum_1.value 70
hum_2.value 72
multigraph netatmo_wind
wind_speed_0.value 15
multigraph netatmo_noise
noise_0.value 34
multigraph netatmo_pressure
pressure_0.value 762.96
multigraph netatmo_temp
temp_0.value 17.7
temp_1.value 19
temp_2.value 19.5
multigraph netatmo_rain_daily
rain_daily_0.value 0.01313
multigraph netatmo_co2
co2_0.value 498
co2_1.value 362
multigraph netatmo_wind_angl
wind_angle_0.value 20
multigraph netatmo_wind_gust_angl
gust_angle_0.value 7

third run:

multigraph netatmo_temp
temp_0.value 17.7
temp_1.value 19
temp_2.value 19.5
multigraph netatmo_co2
co2_0.value 498
co2_1.value 362
multigraph netatmo_wind_angl
wind_angle_0.value 20
multigraph netatmo_wind_gust_angl
gust_angle_0.value 7
multigraph netatmo_pressure
pressure_0.value 762.96
multigraph netatmo_humidity
hum_0.value 75
hum_1.value 70
hum_2.value 72
multigraph netatmo_wind
wind_speed_0.value 15
multigraph netatmo_noise
noise_0.value 34
multigraph netatmo_rain_daily
rain_daily_0.value 0.01313

as you can see 1 - data but not all 2 - more data but not all 3 - more data as second

Shizzlebix commented 7 years ago

if i test it minutes after ... same effect

NightMan-1 commented 7 years ago

as i can see, we not have data for netatmo_rain_hourly and netatmo_wind_gust ... api problem? can you make example app with this api - https://github.com/romainbureau/netatmo-api-go ?

go
package main

import (
    "fmt"
    "os"

    netatmo "github.com/romainbureau/netatmo-api-go"
)

func main() {

    n, err := netatmo.NewClient(netatmo.Config{
    ClientID:     "YOUR_APP_ID",
    ClientSecret: "YOUR_APP_SECRET",
    Username:     "YOUR_CREDENTIAL",
    Password:     "YOUR_PASSWORD",
    })
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    dc, err := n.Read()
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    for _, station := range dc.Stations() {
        fmt.Printf("Station : %s\n", station.StationName)

        for _, module := range station.Modules() {
            fmt.Printf("\tModule : %s\n", module.ModuleName)

            ts, data := module.Data()
            for dataType, value := range data {
                fmt.Printf("\t\t%s : %s (%d)\n", dataType, value, ts)
            }
        }
    }
}
Shizzlebix commented 7 years ago

Station : Pleasure Dome Module : Outdoor Temperature : %!s(float32=17.4) (1508942072) Humidity : %!s(int32=76) (1508942072) LastMesure : %!s(int64=1508942072) (1508942072) Module : Niederschlagsmesser Rain : %!s(float32=0) (1508942085) Rain1Hour : %!s(float32=0) (1508942085) Rain1Day : %!s(float32=1.313) (1508942085) LastMesure : %!s(int64=1508942085) (1508942085) Module : Indoor 1 Temperature : %!s(float32=19.1) (1508942072) Humidity : %!s(int32=70) (1508942072) CO2 : %!s(int32=557) (1508942072) LastMesure : %!s(int64=1508942072) (1508942072) Module : Windmesser LastMesure : %!s(int64=1508942091) (1508942091) WindAngle : %!s(int32=50) (1508942091) WindStrength : %!s(int32=20) (1508942091) GustAngle : %!s(int32=38) (1508942091) Module : Indoor AbsolutePressure : %!s(float32=1001.3) (1508942096) LastMesure : %!s(int64=1508942096) (1508942096) Temperature : %!s(float32=19.8) (1508942096) Humidity : %!s(int32=72) (1508942096) CO2 : %!s(int32=542) (1508942096) Noise : %!s(int32=38) (1508942096) Pressure : %!s(float32=1017.6) (1508942096)

NightMan-1 commented 7 years ago

Can you give me access to your netatmo account? It's will be very helpful for fastest and easy debug. My email sergey@fsky.info

Shizzlebix commented 7 years ago

./done i had invite you or do your mean not guest...... directly my account?

NightMan-1 commented 7 years ago

Thanks for invite! Now all must work, please test :)

NightMan-1 commented 7 years ago

1) https://github.com/romainbureau/netatmo-api-go - not have all data 2) https://github.com/exzz/netatmo-api-go - not have GustStrength data 3) https://github.com/exzz/netatmo-api-go/pull/5

Shizzlebix commented 7 years ago

thank you i will test -> first look, it looks good

NightMan-1 commented 7 years ago

go get github.com/NightMan-1/netatmo-api-go

I made fork for API

Shizzlebix commented 7 years ago

it was my mistake im sorry

Shizzlebix commented 7 years ago

what i dont understand are the data from rain :( it says 101 m (what is m?) why 101? the scale says (correct) 1,01mm

Shizzlebix commented 7 years ago

Hey nighty ;) In th api there is a way now.... to get Systeminfos like WLAN or battery status

Add Info function to display RF, wifi and battery levels

Can we also this draw in munin pls?