Commit 02639796 authored by Josh Proehl's avatar Josh Proehl
Browse files

Doc updates

parent 906d24d0
......@@ -36,6 +36,36 @@ If none is defined it will start a pubsub named :weatherflow_tempest and output
## Usage
You can get the latest data heard from the station via `WeatherflowTempest.get_latest`, which will return a map
containing the last received message of each message type.
To subscribe to all events use the convenience function `WeatherflowTempest.PubSub.subscribe_udp_events()`,
and then handle all incoming events with something like:
def handle_info(%{topic: "weatherflow:udp", event: event_type, payload: payload} = msg, socket) do
Logger.debug("Got event type #{msg.event}")
{:noreply, socket}
The broadcasts use `%Phoenix.Socket.Broadcast{}` structs, the topic is set as "weatherflow:udp", the event represents
the type of event, and the payload is the flattened and transformed payload from the Weatherflow station.
The events returned are fullname-expanded versions of the type codes of the WeatherFlow API:
- :event_precipitation
- :event_strike
- :rapid_wind
- :observation_air
- :observation_sky
- :observation_tempest
- :device_status
- :hub_status
The payload for each event is transformed from the UDP API format by `WeatherFlowTempest.Client`, but in short it will
be a map containing all data returned by the API as key/value pairs.
It is worth noting that the type key is stripped from the results (due to us changing the event names to be clearer),
so if you are passing the messages on further you will need to keep the association between object and type manually.
## License
......@@ -2,7 +2,9 @@ defmodule WeatherflowTempest.Client do
@moduledoc """
Listens for packets from Weatherflow devices on the LAN and stores their latest state/update in its own state.
Outputs events via Phoenix PubSub on channel name :weatherflow_tempest
Outputs events via `WeatherflowTempest.PubSub.udp_event_broadcast/2`.
Events containing observations are flattened into a single observation with all observation keys as top-level keys.
use GenServer
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment