Ambient Weather available locally now. Integration anyone?

So, every minute I get this in the logs:

Exception in update when dispatching 'awnet_local_data_update_48:3f:da:54:c1:45': () Traceback (most recent call last): File "/config/custom_components/awnet_local/__init__.py", line 146, in update self._ambient.stations[self._mac_address][ATTR_LAST_DATA][ KeyError: 'yearlyrainin'
Exception in update when dispatching 'awnet_local_data_update_48:3f:da:54:c1:45': () Traceback (most recent call last): File "/config/custom_components/awnet_local/__init__.py", line 146, in update self._ambient.stations[self._mac_address][ATTR_LAST_DATA][ KeyError: 'batt_25in'
Exception in update when dispatching 'awnet_local_data_update_48:3f:da:54:c1:45': () Traceback (most recent call last): File "/config/custom_components/awnet_local/__init__.py", line 146, in update self._ambient.stations[self._mac_address][ATTR_LAST_DATA][ KeyError: 'batt_25'
Exception in update when dispatching 'awnet_local_data_update_48:3f:da:54:c1:45': () Traceback (most recent call last): File "/config/custom_components/awnet_local/__init__.py", line 146, in update self._ambient.stations[self._mac_address][ATTR_LAST_DATA][ KeyError: 'winddir_avg2m'
Exception in update when dispatching 'awnet_local_data_update_48:3f:da:54:c1:45': () Traceback (most recent call last): File "/config/custom_components/awnet_local/__init__.py", line 146, in update self._ambient.stations[self._mac_address][ATTR_LAST_DATA][ KeyError: 'windspdmph_avg10m' 

Is there a way to avoid these error logs from awnet_local?

If anyone has been having issues with the WS-5000 devices, I just put out an update for the add-on that should take care of that problem. Seems that they send through a malformed HTTP request.

Also, @sfatula your log issue should be taken care of in the latest release of the integration.

If there are any further issues, please create GitHub issues, as they are easier for me to track (working on getting notifications setup for this thread, too).

1 Like

@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.