Skip to the content.
Weather Plug-in - Weather with MQTT Weather with MQTT

The Weather plug-in can send via MQTT selected current and forecast weather items, if available in the retrieved weather data.

MQTT Setup

Setup is done in the Ctrl/Web/MQTT Vars tab. See the MQTT Setup section of HV Controller Weather Variables for details.

Sending Weather Information

Weather information can be sent via MQTT whenever a weather fetch is done. To send weather information via MQTT, the Weather plug-in uses the defined State Topic.

Current and/or forecast weather is sent in separate MQTT messages with the same topic. The payload is in JSON format.

Current weather example (formatted for readability):

{
    "wx": {
        "location":"Lincroft, New Jersey, US",
        "lat":40.36,
        "long":-74.13,
        "temp":"66 F (19 C)",
        "humidity":72,
        "pressure":"29.88\"",
        "weather":"Clear sky",
        "wind":"From the southwest at 3 MPH",
        "uvi":0,
        "sunrise":"06:50:04 AM",
        "sunset":"06:43:59 PM"
    }
}

Forecast weather example (formatted for readability):

{
    "fc": {
        "loc": "Lincroft, New Jersey, US",
        "time":"28 Sep 2021 03:33:16 PM",
        "day1": {
            "clouds": 76,
            "day": "Tue",
            "flhi": 73,
            "lc": "Moderate rain",
            "pop": 100
        },
        "day2": {
            "clouds": 1,
            "day": "Wed",
            "flhi": 65,
            "lc": "Clear sky",
            "pop": 5
        },
        "day3": {
            "clouds": 17,
            "day": "Thu",
            "flhi": 61,
            "lc": "Few clouds",
            "pop": 0
        }
    }
}

Note that in the forecast payload, there may be some general items, like "loc", and then forecast-day specific items. These are grouped under "day1", "day2", etc.. Only days that have Active variables will show up. For example, if you only made Active items for "Day2" and "Day4", there will be no "Day1", "Day3", "Day5", "Day6" or "Day7" in the JSON payload.

Controlling Weather Settings

To control weather settings via MQTT, the Weather plug-in uses the defined Command Topic.

The payload to use is identical to the syntax of the "WeatherSetVar" and "WeatherSet" commands.

Examples, assuming the Command Topic is set to "cmnd/weather/set":

Set Location Selection to "HVLatLong":

    Topic: cmnd/weather/set
    Payload: "WeatherSet HVLatLong"

Set Location Selection to "Lat/Long", with new values:

    Topic: cmnd/weather/set
    Payload: "WeatherSet LatLong 40 -74"

Set Data Source to "NWS" for both current and forecasts:

    Topic: cmnd/weather/set
    Payload: "WeatherSet NWS"

Set Data Source to "OpenWeather" for forecasts:

    Topic: cmnd/weather/set
    Payload: "WeatherSet forecast OpenWeather"

Trigger a Weather fetch in the background:

    Topic: cmnd/weather/set
    Payload: "WeatherSetVar"

See Triggering Weather Fetches for complete details of the WeatherSet and WeatherSetVar syntax.

See Also:
Introduction to the Weather Plug-in
Web-Based Weather Data
Using Weather Control Variables
Forecast Examples
HV Controller Weather Variables
Local Weather Data Files
Speaking Weather Data
Triggering Weather Fetches
Weather Websockets
Custom Objects and Websockets
Weather Info for NetIO
Disclaimer