Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

github.com/tris/weatherflow

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tris/weatherflow


Version published
Created
Source

weatherflow

weatherflow is a Go module for streaming rapid observations from the WeatherFlow Tempest API.

Installation

go get -u github.com/tris/weatherflow

Example

import (
	"fmt"
	"log"
	"github.com/tris/weatherflow"
)

func main() {
	client := weatherflow.NewClient("your-token-here", nil, log.Printf)

	client.AddDevice(12345)

	client.Start(func(msg weatherflow.Message) {
		switch m := msg.(type) {
		case *weatherflow.MessageObsSt:
			fmt.Printf("Observation: %+v\n", m)
		case *weatherflow.MessageRapidWind:
			fmt.Printf("Rapid wind: %+v\n", m)
		}
	})

	time.Sleep(30 * time.Second)

	client.Stop()
}

Limitations

  • Only Tempest and Rapid Wind observations are passed:
    • Acknowledgement (ack)
    • Rain Start Event (evt_precip)
    • Lightning Strike Event (evt_strike)
    • Device Online Event (evt_device_online)
    • Device Offline Event (evt_device_offline)
    • Station Online Event (evt_station_online)
    • Station Offline Event (evt_station_online)
    • Rapid Wind (3 sec) (rapid_wind)
    • Observation (Air) (obs_air)
    • Observation (Sky) (obs_sky)
    • Observation (Tempest) (obs_st)

Known issues

  • obs_st messages are unreliable. In particular, if you issue listen_start for the same device on two separate WebSocket connections, both will reply with ack but only the first connection will receive any obs_st messages, save for an initial reading from cache.

    You can verify this behavior using wscat (run two copies):

    wscat -c wss://ws.weatherflow.com/swd/data?token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -x '{"type":"listen_start","device_id":123456,"id":""}' -w 180
    

    This does not seem to be an issue for rapid_wind messages.

    Note that Add() will issue both listen_start and listen_rapid_start; there is currently no way to listen only to one type. (I may change this in the future if WeatherFlow says the aforementioned behavior is intentional.)

    Further details: WebSocket API issue with obs_st messages

Credit

I took a bit of inspiration from the excellent goweatherflow module, which you should use instead if your Tempest is on the same LAN.

FAQs

Package last updated on 24 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc