Giter VIP home page Giter VIP logo

home-assistant-esphome-weather-station's Introduction

Home-Assistant-ESPHome-Weather-Station

Nextion display with ESP8266 microcontroller (Wemos D1 mini) showing Home Assistant temperature sensors (temperature inside, outside and in the swiming pool) and weather forecast from the internet. But you might display any Hassio sensors, so if you wish to create own weather forecast, you can do that.

Temperatures Forecast

Buy me a coffee

Getting Started

Architecture

The Nextion display is connected via 4 wires: GND, +5V, RX, and TX. So to control the display is extremely easy - just connect these 4 wires to the corresponding ports in an Arduino board and you are set. In this project, I am using Wemos D1 mini. But in some other projects, I have the display connected to Sonoff 4ch or even Sonoff Basic (the only challenge with these is to find the pin with 5V, but this is not that hard).

Design

The principle is very simple: I used Nextion Editor to create a layout for the display screen. There is a static image background with all graphics that do not change (including text, icons, frames, or color background). On top of the background, I created text or image objects for all the values that change. When the design is finished, you can upload the layout to the display from the NextionEditor using the serial connection (via USB FTDI board).

The program is then very simple - it just sets the text value for the individual text objects. For example, for the inside temperature it does this:

it.set_component_text_printf("inside","%2.1f",id(temperature_inside).state);

ESPHome can read Home Assistant sensors through API, so the ESPHome sensor "teplota_uvnitr" is linked to Home Assistant sensor sensor.teplota_uvnitr this way:

sensor:
  - platform: homeassistant   # Inside temperature
    id: teperature_inside
    entity_id: sensor.temperature_inside

The weather forecast uses a picture - I have loaded set of icons through the NextionEditor, so all I do us to change the picture id this way:

it.send_command_printf("%s.pic=%.0f", "weather",id(today_icon).state);

For the ESPHome to communicate, the HMI also needs to be configured not to send responses on the commands. It is also a good idea to increase the port speed. To do that, in the Nextion Editor, in the Program.s tab, add these two commands before the page line.

baud=115200
bkcmd=0

It is using the 2.4 inch Nextion display.

Additional features

There are two more "nice to have" features:

  1. The display has 2 pages. I made it so it does change the page on each refresh (every 5 seconds). This is optional, you can make it either to show one page only. Or to flip the page on touching the screen (this can be easily done directly from the NextionEditor, without any programming).
  2. On my Home Assistant, I also have a sensor showing whether somebody is home. When the alarm is on, nobody is home - so I am turning off the display light. And I only update the information when the display is on. This is entirely optional.
  3. I also display the internet time, using ESPHome's time service.

Source files

  • display_weather.yaml - this is the main file - the actual ESPHome configuration
  • display.HMI - this is the actual design of the display I use - the file can be edited via the NextionEditor (can be downloaded from ITEAD pages)
  • weather.yaml - Home Assistant configuration of the weather sensors I use. You can obviously use any sensors or any other weather service you like. Additionally, I have 3 temperature sensors - one of them is Z-Wave temperature sensor (internal). The other sensors are created through ESPHome. I also have luminosity sensor and rain sensor (but I do not show these, they are used in various automations). It is really up to you what information you find useful to show.
  • images (folder) - I have included the source images for the Nextion display editor. These are not essential for the project, but if you want to create own design, you can start from there.
  • 3D model front.stl, 3D model back.stl - 3D model of the box the display is mounted in (Wemos D1 mini fits in the back).

Author

  • Václav Chaloupka - Initial work - bruxy70

home-assistant-esphome-weather-station's People

Contributors

bruxy70 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

home-assistant-esphome-weather-station's Issues

[Question] temperature icons

Hi Vaclav,

first of all thank you very much for this project. I made one for me too, and I used the 3d print model - fits perfectly.

But since, I don't have a pool I would like to put there other measurement and here is the question: from where you took the icons?
I would like to find one with similar look for the other measurement (it will be humidity actually).

PS. I am watching your YT videos. Keep it up!
Greetings from Poland.

lost completely

watched some of your videos aswell as trying to understand the code.
Even no problem with the GUI editor from nextion.
But what's missing is another 5min to your videos about the HOW TO integrate things with HA.
A simply .. this should go there .. isn't enough information.
Same applies to the HMI file. I'm lost guessing if this must be warped into the display onto an SD bumped into the displays SD card slot or simply should sit inside a HA ESPhome project.
Since so, thanks for spreading the word and videos about that things should work as expexted but it's still a miracle to me about how to get these things together. Looks to me as if I did understand if ever 10% of all steps one has to do.
Perhaps you could do another video showing the step by step about where to place each single file from here into which target, let if be ESPhome or HA.

Waiting for ACK timed out!

Thank you for the creating this.
I have been playing with my nextion for a long time but am not able to get it to work with any programming.
The only thing i do get is:

[14:26:02][W][nextion:036]: Waiting for ACK timed out!
[14:26:02][W][nextion:083]: Sending command 'outside.txt="21.6"' failed because no ACK was received

I did change the pins around in the software and physical but nothing works

I am using a 5" display but that should not really care i guess
I also did try with another 2.4 display with the same thing

`# This is ESPHome configuration file. This goes to the esphome folder

You need to provide your WiFi ssis/password and passwords for API and OTA (or put them in your esphome/secrets.yaml)

esphome:
name: display_weather
platform: ESP8266
board: d1_mini_pro

wifi:
ssid: SSID
password: PASS
fast_connect: true

api:
password: PASS

ota:
password: PASS

logger:
baud_rate: 0 # Disable UART logging (pins GPIO1/3 are used for Nextion communication)

uart:
rx_pin: D1
tx_pin: D6
baud_rate: 9600

time:

  • platform: sntp
    id: sntp_time

sensor:

  • platform: homeassistant # Inside temperature
    id: temperature_inside
    entity_id: sensor.kantoor_temperatuur

  • platform: homeassistant # Outside temperature
    id: temperature_outside
    entity_id: sensor.tuin_temperatuur

  • platform: homeassistant # Swimming pool
    id: temperature_pool
    entity_id: sensor.keuken_koelkast_temperatuur

  • platform: homeassistant # Forecast minimal temperature
    id: today_min
    entity_id: sensor.today_min

  • platform: homeassistant # Forecast maximal temperature
    id: today_max
    entity_id: sensor.today_max

  • platform: homeassistant # Forecast precipitation
    id: today_rain
    entity_id: sensor.today_rain

  • platform: homeassistant # Forecast icon
    id: today_icon
    entity_id: sensor.today_icon

binary_sensor:

  • platform: homeassistant
    id: somebody_home
    entity_id: binary_sensor.kantoor_beweging

globals:

  • id: first_page # First page of the display?
    type: bool
    restore_value: no
  • id: display_on # Is display on?
    type: bool
    restore_value: no

display:

  • platform: nextion
    id: teplomer
    update_interval: 5s
    lambda: |-
    // Turn display on when somebody is home. Only update when display on.
    if (id(somebody_home).state) {
    if (!id(display_on)) {
    it.set_backlight_brightness(50);
    id(display_on)=true;
    }
    // Swich first/second page on each update (every 5 seconds)
    if (id(first_page)) {
    it.goto_page("forecast");
    it.send_command_printf("%s.pic=%.0f", "weather",id(today_icon).state);
    it.set_component_text_printf("minmax","%.0f/%.0f",id(today_min).state,id(today_max).state);
    if (isnan(id(today_rain).state)) {
    it.set_component_text("rain","-");
    } else {
    it.set_component_text_printf("rain","%.0f",id(today_rain).state);
    }
    auto time = id(sntp_time).now();
    it.set_component_text_printf("hour","%02d",time.hour);
    it.set_component_text_printf("minute","%02d",time.minute);
    } else {
    it.goto_page("temperature");
    it.set_component_text_printf("inside","%2.1f",id(temperature_inside).state);
    it.set_component_text_printf("outside","%2.1f",id(temperature_outside).state);
    it.set_component_text_printf("pool","%2.1f",id(temperature_pool).state);
    }
    id(first_page) = !id(first_page); // Switch page
    } else {
    // Turn off the display if nobody is home.
    if (id(display_on)) {
    it.set_backlight_brightness(0);
    id(display_on)=false;
    }
    }`

HMI file issues

I downloaded the HMI file but on trying to open it in the Nextion editor I get an error message and the file fails to open.
"Wrong resource file or resource file has been damaged"

Display don´t show any values

Hi!
I followed your guide 100% but I dont get the display to show values from sensors, it just shows the first picture and not changes pictures eather.

What do I wrong?

display not updating

hi fairly new to the nextion display so unsure if iv done this correctly
flashed d1 mini with the weather yamel no problems
loaded the hmi file into the latest Nextion Editor and exported a .tfi file which i then flash onto the display again all good so far
now hook up the rx tx and power everything boots up and display powers up but the sensors dont get populated and doesnt flick between the two pages. only thing i can do is press the plus n minus buttons on the screen for brightness.
i added the example sensors to my configuration.yamel they show up in home assistant

i feel iv probably missed something obvious :) but stuck
thanks

sun_elevation feature

Trying to fit your code with my needs I found this:

if (id(sun_elevation)>0) {

It seems it doesn't work for me unless I add here:

if (id(sun_elevation).state>0) {

PS. Finally I replaced this with the Xiaomi illuminance value, which I find more suited for this functionality.

using TFT display with spi.

Is it possible to run your project on TFT with spi interface?
I wanted to make weather station by adafruit, but I liked your project more. The display I bought is TFT 2.4 spi touch.

no ACK was received

I tried to copy your weather station.. and i would like a button on the nextion display to show the real world state of a light.. when it is turned ON by the physical switch.. like when its ON then the button on the nextion display would change too... I manage to turn the lights ON or OFF via nextion display button.. but i had no luck in changing its actual state if i turn the light ON using the physical switch... it shows OFF on the nextion display button.. and i have a error log on esphome like this...

Sending command 'lightlamp.pic = 1' failed because no ACK was received

here is part of my esphome config..

display:

  • platform: nextion
    id: lightdisplay
    update_interval: 5s
    lambda: |-
    if (id (light_status) .state) {
    it.send_command_printf ("lightlamp.pic = 1");
    } else {
    it.send_command_printf ("lightlamp.pic = 0");
    }

Do you know what am i missing here? thanks !

nextion display is not working after network disconnect

Hello there.

I have cloned your project successfully with all the hmi/code uptodate changes with esphome 2021.11.1 and nov home assistant as well.

The phenomena I'm facing is that after a sudden network disconnect esphome is able to connect again to the nodemcu but it seems that display lambda loop is not running anymore.

INFO nextion_test.local: Ping timed out!
INFO Disconnected from ESPHome API for nextion_test.local
WARNING Disconnected from API
INFO Successfully connected to nextion_test.local
[17:45:55][D][sntp:075]: Synchronized time: 2021-11-28 17:45:55
[17:45:56][D][api:098]: Accepted 192.168.86.80
[17:45:56][D][api.connection:747]: Home Assistant 2021.11.5 (192.168.86.80): Connected successfully
[17:45:56][D][homeassistant.sensor:024]: 'sensor.temperature_158d00022266cc': Got state 23.20
[17:45:57][D][sensor:113]: 'temperature_outside': Sending state 23.20000 with 1 decimals of accuracy

Is this phenomena familiar to you? can you tell how to restart both nextion and esp processor in case of network reconnect and get back to the display loop?

Regards
Asaf

Display not showing any values

Hi there,

I've built the device, but the display is not showing any value unfortunately. I don't know where the problem can be. I have similar setup to you, the homeassistant sensors values are being shown on ESPHome Log with the display connected, pins correctly set, but still no values on the display. Right now using the same lambda as you, but getting weird warning during compilation:

Compiling /data/meteo1/.pioenvs/meteo1/src/main.cpp.o
src/main.cpp:255:3: warning: multi-line comment [-Wcomment]
// lambda: !lambda " Do not wait for ack (this delays the whole procedure a lot, and
^

Anyway I tried such simple lambda like this:
it.set_wait_for_ack(false);
it.set_component_text_printf("inside","%2.1f",id(temperature_inside).state);

which doesn't show any warning during compilation, but inside temperature is not shown anyway

[15:38:06][C][sntp:043]: SNTP Time:
[15:38:06][C][sntp:044]: Server 1: '0.pool.ntp.org'
[15:38:06][C][sntp:045]: Server 2: '1.pool.ntp.org'
[15:38:06][C][sntp:046]: Server 3: '2.pool.ntp.org'
[15:38:06][C][sntp:047]: Timezone: 'CET-1CEST-2,M3.5.0/2,M10.4.0/3'
[15:38:06][C][homeassistant.binary_sensor:032]: Homeassistant Binary Sensor 'somebody_home'
[15:38:06][C][homeassistant.binary_sensor:033]: Entity ID: 'binary_sensor.somebody_home'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'sun_elevation'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.sun_elevation'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'temperature_inside'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.teplota_loznice'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'temperature_outside'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.temperature_outside'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'temperature_pool'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.temperature_pool'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'today_min'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.today_min'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'today_max'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.today_max'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'today_rain'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.today_rain'
[15:38:06][C][homeassistant.sensor:024]: Homeassistant Sensor 'today_icon'
[15:38:06][C][homeassistant.sensor:024]: Unit of Measurement: ''
[15:38:06][C][homeassistant.sensor:024]: Accuracy Decimals: 1
[15:38:06][C][homeassistant.sensor:025]: Entity ID: 'sensor.today_icon'
[15:38:09][D][api.connection:583]: Client 'Home Assistant 0.104.0 (10.10.110.35)' connected successfully!
[15:38:09][D][sntp:059]: Synchronized time: Thu Jan 16 15:38:09 2020
[15:38:10][D][homeassistant.binary_sensor:021]: 'binary_sensor.somebody_home': Got state ON
[15:38:10][D][binary_sensor:034]: 'somebody_home': Sending initial state ON
[15:38:10][D][homeassistant.sensor:019]: 'sensor.teplota_loznice': Got state 21.60
[15:38:10][D][sensor:092]: 'temperature_inside': Sending state 21.60000 with 1 decimals of accuracy
[15:38:10][D][homeassistant.sensor:019]: 'sensor.today_min': Got state -3.10
[15:38:10][D][sensor:092]: 'today_min': Sending state -3.10000 with 1 decimals of accuracy
[15:38:10][D][homeassistant.sensor:019]: 'sensor.today_max': Got state 7.50
[15:38:10][D][sensor:092]: 'today_max': Sending state 7.50000 with 1 decimals of accuracy
[15:38:10][D][homeassistant.sensor:019]: 'sensor.today_rain': Got state 0.10
[15:38:10][D][sensor:092]: 'today_rain': Sending state 0.10000 with 1 decimals of accuracy
[15:38:10][D][homeassistant.sensor:019]: 'sensor.today_icon': Got state 8.00
[15:38:10][D][sensor:092]: 'today_icon': Sending state 8.00000 with 1 decimals of accuracy

problem UART comunication

Hi I'm testing your weather station with an esp d1 mini and a 3.5 inch nexion display, I loaded the yaml on esp home and everything works, the data updates, but uart doesn't communicate between nexion and d1 mini? what can it be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.