# Weather hat and MQTT to Home Assistant

**URL:** <https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820>\
**Category:** Support\
**Created:** [November 27, 2022, 5:49pm UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820 "2022-11-27T17:49:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakj](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hakj](https://forums.pimoroni.com/u/hakj)\
**Post date:** [November 27, 2022, 5:49pm UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/1 "2022-11-27T17:49:18Z")

</div>

Hello

I am trying to find instructions on how to set up the Pimoroni Weather hat to send meassages to Mqtt.  
Is it possible to find the instructions somewhere?

---

<div class="post-metadata">

**Author:** ![hel](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/hel/32/6075_2.png) [@hel](https://forums.pimoroni.com/u/hel)\
**Post date:** [November 28, 2022, 10:01am UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/2 "2022-11-28T10:01:01Z")

</div>

It’s been a while since I used it, but this is the Python code I ran on my Pi to post my Weather HAT data into Home Assistant: [Weather HAT - MQTT for Home Assistant · GitHub](https://gist.github.com/helgibbons/5c93d0504398cd457e504aa7f8aeff25).

You’ll need to add your MQTT broker details (I used the Mosquitto add-on in HA as my broker) and install the MQTT integration in HA to be able to work with MQTT sensors. I think there are some decent guides online for setting up MQTT in Home Assistant if you need help with this?

I think this Python script works with Home Assistant’s auto-discovery, so if the MQTT stuff is up and running your new sensors should automatically appear in your Home Assistant overview…

---

<div class="post-metadata">

**Author:** ![ltoolio](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/ltoolio/32/9827_2.png) [@ltoolio](https://forums.pimoroni.com/u/ltoolio)\
**Post date:** [May 10, 2023, 4:24am UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/3 "2023-05-10T04:24:59Z")

</div>

Adding a successful usage of the solution referenced above. Got me exactly what I wanted with minimal effort.

---

<div class="post-metadata">

**Author:** ![hakj](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hakj](https://forums.pimoroni.com/u/hakj)\
**Post date:** [May 27, 2023, 8:12am UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/4 "2023-05-27T08:12:42Z")

</div>

Worked perfect, thank you!  
How do you present the data on the dashboard? Do you have a special card for that? Or statistics?  
Do you know how I can load this script on startup?

---

<div class="post-metadata">

**Author:** ![hakj](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hakj](https://forums.pimoroni.com/u/hakj)\
**Post date:** [May 28, 2023, 3:12pm UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/5 "2023-05-28T15:12:11Z")

</div>

I have one issue with the file. I don`t get the wind direction into home assistant. I can see it posting direction on the broker with mqtt explorer. The value is east, south, south east…  
In home assistant the value comes up as unknown.  
How can I change the python file so it shows up in home assistant?

---

<div class="post-metadata">

**Author:** ![hakj](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hakj](https://forums.pimoroni.com/u/hakj)\
**Post date:** [May 29, 2023, 11:25am UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/6 "2023-05-29T11:25:16Z")

</div>

Did you get the wind-direction into Home assistant? I only get unknown. In MQTT i can see the values west, east and so on.  
I would prefer to get the degrees delivered to Home assistant since most of the lovelace cards uses degrees.

---

<div class="post-metadata">

**Author:** ![hakj](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hakj](https://forums.pimoroni.com/u/hakj)\
**Post date:** [June 1, 2023, 9:23am UTC](https://forums.pimoroni.com/t/weather-hat-and-mqtt-to-home-assistant/20820/7 "2023-06-01T09:23:25Z")

</div>

I have a problem with the wind sensor not sending to Home Assistant.  
All the other sends data all the time, but Windsensor stops sending after a while. How can I check this sensor?
