Ambient Weather available locally now. Integration anyone?

@tlskinneriv - I was pleasantly surprised today to see that’s is now gathering data. thank you!

Finally got around to migrating. This is great!

@Anwen @tankdeer can you point me in the right direction to set this up without the Supervisor? I tried ambientweather2mqtt but the sensors aren’t populating via that program. I’m not sure why as the logs only say connected to mqtt… no errors. :man_shrugging:

I haven’t tried ambientweather2mqtt, I just have a Python program running as a service on my Ubuntu host as linked in my post above, and an MQTT docker container running connected to HA with the MQTT integration. Can you see the weather data MQTT messages if you look with either the MQTT integration in HA, or with something like MQTT Explorer? How are you running HA?

I have the python script, that you linked above, running in a ubuntu LXC, currently. I can see the data from my weather station. I can see it connected to my local EMQX which is in another container. It is not publishing MQTT topics to the server though for some reason. I don’t see any errors. The only thing I can see on MQTT explorer a topic from weather/ that says offline but it’s obviously connected to my EMQX.

I’m running HA Operation System in a Proxmox VM at the moment. I use the addon AWnet to local at the moment but want to move my HA to an LXC so no more addons. This is one of two I still need to find a solution for. I’d rather not use the cloud version if I don’t have to.

I can see all my weather station data in MQTT Explorer. It seems odd that you can see the offline topic but not the others - maybe something is not quite right with your Python script? (I actually ended up commenting out the lines of code that generate that topic in the Python script because it doesn’t seem to serve any purpose.)

I defined all my sensors in HA using MQTT discovery. This post was really helpful in figuring out how to make them:

I have a big script that I ran to define them, the beginning of it looks like this:

mqtt_weather_station_sensors_create:
  alias: 'MQTT Create WS Sensors'
  sequence:
    - service: mqtt.publish
      data:
        topic: homeassistant/sensor/ws2902c_stationtype/config
        retain: true
        payload: |
          {
            "name": "WS Station Type",
            "unique_id": "ws_stationtype",
            "state_topic": "weather/ws-2902c/stationtype",
            "icon": "mdi:weather-partly-snowy-rainy",
            "device": {
                "identifiers": ["Ambient Weather"],
                "name": "Ambient Weather Station",
                "model": "WS-2902C",
                "manufacturer": "Ambient Weather",
                "sw_version": "4.3.2"
            }
          }
    - service: mqtt.publish
      data:
        topic: homeassistant/sensor/ws2902c_pressure_abs/config
        retain: true
        payload: |
          {
            "name": "WS Abs Barometric Pressure",
            "unique_id": "ws_baromabs",
            "state_topic": "weather/ws-2902c/baromabsin",
            "icon": "mdi:gauge",
            "unit_of_measurement": "inHg",
            "device": {
                "identifiers": ["Ambient Weather"],
                "name": "Ambient Weather Station",
                "model": "WS-2902C",
                "manufacturer": "Ambient Weather",
                "sw_version": "4.3.2"
            }
          }

This is truncated - the full script has an mqtt_publish entry for every weather station sensor. The device section creates a device in HA, which is nice to have. You don’t have to do it this way, but when HA deprecated the old style MQTT sensors I decided to redo mine like this.

Not sure if any of that helps…

I am still learning python so it’s a bit beyond my skill set lol. I copied the script from the above link and followed those directions. I changed the MQTT variables to point at my MQTT. The script says it connects and sends that “offline” message. The only other thing I changed was the listening port. Even checking topics in the EMQX GUI I see nothing for weather…that doesn’t even show the offline message. So IDK. Because of my limited skill I tried to keep the script as simple as possible and figure once I got it working could move to other steps. I just can’t figure out why it won’t publish. My Zigbee2mqtt publishes fine. My AgentDVR publishes fine. HA publishes fine…so there’s something in the MQTT part of the code that’s causing it to not publish.

I am also still learning Python, so I totally understand :slight_smile: I think I tweaked a bit to get it to work for me. I can send you a copy of my version via private message if you like (not sure if I should post it here since it isn’t my original work).

Yes please if you don’t mind. I would be extremely greatful. This is the toughest of the two to get switched over. My other is an FTP server and figure that might be a bit easier to figure out.

1 Like

I switched to ambientweather2mqtt and haven’t looked back, as it works perfectly for my needs. He did a lot of work to it semi recently so I don’t know if you’ve tried it since then

Yes I’ve been trying to get it to work for a few days with no luck. It connects but isn’t parsing from my WS for some reason. What Anwen just sent me is working on my Ubuntu LXC and sending to MQTT.

Strange. Glad you got it though

Now just to figure out how to calculate the feels like temp…

Do you get the Illumination sensor? I don’t get it with the original Ambient Weather integration.

No. I abandoned trying to use this and switched to ambientweather2mqtt, which works better for me. However I can tell you that most of the sensors I had issues with are not provided by the local API. The official integration and/or the cloud API calculates them vs being sent from the station itself.

It is strange that I have another automation device called Hubitat. The Ambient Weather integration provides MANY MORE value from that integration. I wonder if any developers out there can compare the two integrations and describe why one provides many more entity values.

@Anwen
@tankdeer
@tlskinneriv

Almost certainly calculated fields You can see the full list of fields that the device might provide, here.

Note at the bottom there is a section for server calculated fields. Those are ones that Ambient calculates on their cloud servers and returns to the integration. Anything not on that list is likely calculated by the integration itself

I created my own versions of the calculated sensors in Home Assistant. I use the Thermal Comfort integration (available in HACS) to get the dewpoint and the heat index, by providing it the outdoor temperature and humidity from my weather station.

Then I made two template sensors - one calculates the wind chill:

platform: template
sensors:
  ws_wind_chill_calc:
    friendly_name: WS Windchill
    value_template: >
      {% set temp = float(states('sensor.ws_temperature_outdoor'), -99) %}
      {% set wind = float(states('sensor.ws_wind_speed'), -99) %}
      {% set wc =  35.74 + 0.6215 * temp - 35.75 * wind**(0.16) + 0.4275 * temp * wind ** (0.16) %}
      {% if wind > 3 and temp < 50 %}
        {% set wchill = wc | round(1) %}
      {% else %}
        {% set wchill = temp %}
      {% endif %}
      {{ wchill }}
    unit_of_measurement: '°F'

and the other calculates the feels like temperature:

platform: template
sensors:
  ws_feels_like_calc:
    friendly_name: WS Feels Like
    value_template: >
      {% set temp = float(states('sensor.ws_temperature_outdoor'), -99) %}
      {% set chill = float(states('sensor.ws_wind_chill_calc'), -99) %}
      {% set heatindex = float(states('sensor.weather_station_heatindex'), -99) %}
      {% if temp <= 50 %}
        {% set feelslike = chill %}
      {% elif temp >= 80 %}
        {% set feelslike = heatindex %}
      {% else %}
        {% set feelslike = temp %}
      {% endif %}
      {{ feelslike }}
    unit_of_measurement: "°F"

I did some research online to figure these out; there may be more accurate formulas somewhere, but these seem to correlate fine with the data given by my local weather providers.

This worked like a charm. But, am unable to import data for wind gust in km/h. It fetches and ingests only in mph.

@tlskinneriv I have tried defining the unit of measurement using customize.yaml but that doesnt help as it just changes the unit but never converts the value.

But, however, for temperature and rain, it’s easy to change units.

Please help here as I don’t want to create a new sensor and convert the units from the UI.

@rishikbsr Just put out an update that should cover your conversion issue. The device only sends the data in mph, so we had to set it as such in the integration. I tested with changing the unit in the UI and validated that it would indeed convert to km/h. If this doesn’t solve your problem, please file an issue in the GitHub repo for the integration.

@capritzl Got a list of the sensors that are missing or you are wanting to see? Latest update should be supporting all of the sensors provided by the built-in HA integration for Ambient Weather. If it didn’t already exist in the built-in HA integration, then likely I haven’t implemented it. There may be one or two outliers to this currently. If the device provides more data that you’re not seeing, then I’d be happy to work to get the values into HA. If it’s a calculated field based on data coming in, that can be worked, too. Feel free to open an issue on the GitHub repo for the integration with more information for what you’re looking for also.

For everybody else: new update, more sensors, better data integration: https://github.com/tlskinneriv/awnet_local/releases/tag/v0.3.0.