Skip to content

Commit

Permalink
Issue-7: json: cannot unmarshal number
Browse files Browse the repository at this point in the history
* Replace int with float64
* Replace sweat drop emoji with droplet emoji
* Update screenshot
  • Loading branch information
ljagiello committed Oct 9, 2023
1 parent 4a21c7a commit 51a9ba7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions airgradient.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ const AIR_GRADIENT_API_URL = "https://api.airgradient.com/public/api/v1/location
type AirGradientMeasures []struct {
LocationID int `json:"locationId"`
LocationName string `json:"locationName"`
Pm01 any `json:"pm01"`
Pm02 int `json:"pm02"`
Pm10 any `json:"pm10"`
Pm003Count any `json:"pm003Count"`
Pm01 float64 `json:"pm01"`
Pm02 float64 `json:"pm02"`
Pm10 float64 `json:"pm10"`
Pm003Count float64 `json:"pm003Count"`
Atmp float64 `json:"atmp"`
Rhum int `json:"rhum"`
Rco2 int `json:"rco2"`
Rhum float64 `json:"rhum"`
Rco2 float64 `json:"rco2"`
Tvoc float64 `json:"tvoc"`
Wifi int `json:"wifi"`
Wifi float64 `json:"wifi"`
Timestamp time.Time `json:"timestamp"`
LedMode string `json:"ledMode"`
LedCo2Threshold1 int `json:"ledCo2Threshold1"`
LedCo2Threshold2 int `json:"ledCo2Threshold2"`
LedCo2ThresholdEnd int `json:"ledCo2ThresholdEnd"`
LedCo2Threshold1 float64 `json:"ledCo2Threshold1"`
LedCo2Threshold2 float64 `json:"ledCo2Threshold2"`
LedCo2ThresholdEnd float64 `json:"ledCo2ThresholdEnd"`
Serialno string `json:"serialno"`
FirmwareVersion any `json:"firmwareVersion"`
TvocIndex int `json:"tvocIndex"`
NoxIndex int `json:"noxIndex"`
FirmwareVersion string `json:"firmwareVersion"`
TvocIndex float64 `json:"tvocIndex"`
NoxIndex float64 `json:"noxIndex"`
}

func fetchMeasures(token string) ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func launched(app appkit.Application, delegate *appkit.ApplicationDelegate) {

// updates to the ui should happen on the main thread to avoid segfaults
dispatch.MainQueue().DispatchAsync(func() {
item.Button().SetTitle(fmt.Sprintf("🌡️ %.2f 💨 %d 💦 %d 🫧 %d",
item.Button().SetTitle(fmt.Sprintf("🌡️ %.2f 💨 %.0f 💧 %.1f 🫧 %.0f",
temperature,
airGradientMeasures[0].Pm02,
airGradientMeasures[0].Rhum,
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 51a9ba7

Please sign in to comment.