LCD Display with MQTT and Home-Assistant notifies

Hi all I am actually sitting in the bus while writing this. I just wanted to shae a project. I am running a esp8266 with a LCD Display.Those is connected to the mqtt broker which listens to topics from hass.

I have an automation which publishes all sensor data to mqtt topic which can be used for the display to show.
How to setup this stuff?

  1. you need a LCD Display connected to an ESP8266
  • ESPEasy https://www.letscontrolit.com/wiki/index.php/ESPEasy (NOTE: The IP should be 192.168.4.1 of your esp after flashing. This is not always the case. Don’t knw why. Maybe because of the Network setting at home here. To figure out the IP of the EsP. Connect to the AP and watch the DNS address n your connection information on windows or your phone)
  • MQTT BRoker (Normally on Home-Assistant install available)
  • Shelscripts to call the api of the LCD

But how to get started?

First connect your LCD Display to the ESYEasy. Descibed well on their page (if Help neededlet me know.)
My config on the espeasy looks like this:
FIrst you go to Controllers and add the OPenHab MQTT CLient.


Fill in your mqtt broker credentials

In Tools you can search for your LCD I2C Display:

You should get something similar like this:

Now it is time to get everything together:

Just go to Devices and add the Display:

The I2C address is what we figured out earlier in I2C scan. Chose the same here
Dont forget “submit” after all setting parameters

Now the Display is ready to receive the commands to show information in the LCD DIsplay.

By default you can also put some Text in Line 1-4 (1-2 depending on your Display.)

For the start we let it empty.

Hw to send information from Home-Assistant to the Display now?

For this we need little scripts / shell commands.

First of oaa you needa shell command which calls a shell script:

### LCD DISPLAY /ON/Off ###
  
  lcd_on: sh /home/hass/.homeassistant/shell_scripts/lcd_on.sh
  lcd_off: sh /home/hass/.homeassistant/shell_scripts/lcd_off.sh

The Shell scrit looks like:

curl http://192.168.1.91/control?cmd=lcdcmd,off
curl http://192.168.1.91/control?cmd=lcdcmd,off

This could be an ALARM PENDING message to the display:

curl http://192.168.1.91/control?cmd=lcdcmd,clear
curl http://192.168.1.91/control?cmd=lcd,1,5,ALARM-SYSTEM
curl http://192.168.1.91/control?cmd=lcd,2,1,--------------------
curl http://192.168.1.91/control?cmd=lcd,3,9,ALARM
curl http://192.168.1.91/control?cmd=lcd,4,6,DEACTIVATED!

The MOST important part here is the “curl http://192.168.1.91/control?cmd=lcdcmd,clear” command. This will clear the display screen of the LCD. If not send to the display. Lines in the Display will be overwritten and will end up in a mess

You just need to adapt the IP of your ESPEasy

Then you can go and try this shell command and see the result. Don’t you worry this will take a lot of time to adjust the text perfectly on the Display :slight_smile:

Advanced use:

lisenting to mqtt topics From Home Assistant and Show them on the display:

For this we need a listener which reads out the values of the topics.

We archive this by subscribing to a topic:

For this we just go to DEVICES and chose MQTT Import:

Never forget to ENABLE the Devices as they are disabled by default.

Just Give It a name. Formula is not needed but feel free to play around.

Don’t forget to SUBMIT each time to save the config.

If you now click again on DEVICES the MQTT the Import MQTT device should show up with the subscribed topic and the Value.

Note: Sometimes for what reason ever the ESP seems frozen. RESET on the ESP should help out here.

After you subscribed to the topic you just need to go to TOOLS --> LOGS and watch the IMPORT valie. THis is something with [yourtopicname#blabla] copy all of this in a Line of your LCD Display and you should be fine.

Sorry I just got a frozen ESP :slight_smile: Let me continue as soon as I fixed. But for the moment With the shell commands without MQTT it should work for you.

UPDATE: Make 100% sure you have the right credentials and IP for the broker. If not the ESP will end up in a loop and wont boot up!

Here is one example. Fell free to try and modify

Here some pics.If someone is interested I will write up the whole thing :wink:

Let’s see it in action:

8 Likes

that’s very interesting. good job. You don’t mind sharing

1 Like

I will share this project if wanted :wink: let me do this this week . I’m busy firbthe moment but if u r interested I’ll certainly share

2 Likes

Yes please! Did you sort out how to automatically turn backlight on and off based on mqtt payloads?

1 Like

this is awesome if you can share will be great

Tutorial done

Thanks so much for this complete tutorial, just in time for my Christmas presents! (just to let you know, I’m making nodes that tells you how much solar power is available near washing machines and most demanding appliances). Will report you as soon as it’s finished!

U r most welcome .I’m playing around what thus easyesp is also able to do … Nice stuff … Waiting your response :wink:

nice project.
thanks for sharing.
how to send mqtt topics to lcd display?
can we send value template data to lcd display?
thanks

Morning. You don’t send topics to the LCD but subscribe to your topics from has. I will extend the tutorial with that function .you can also send topics to has. For the moment I found one topic only bit it should b possible to create more topics … If u add sensors to the esp u should be able to create those topics that has can subscribe to them .bit let me checkow to use templates

@thundergreen
Need some help with MQTT i can send only numbers no text via MQTT are you sending text? what is your LCD/Display screen look like in ESPEasy?

You have the same issue like me. Dunno how to send text but would be nice if we could get this working :wink:

Ok currently using Node Red and sending changes via HTTP node works like a charm! :smile:

1 Like

could u please make a detailed description. Like this i will add this to the first post. Does text also work?

1 Like

Hi everybody,

I’m digging up this topic, because I followed the tutorial, but when I create a .sh with the text:

curl http://192.168.1.91/control?cmd=lcdcmd,clear
curl http://192.168.1.91/control?cmd=lcd,1,5,ALARM-SYSTEM
curl http://192.168.1.91/control?cmd=lcd,2,1,--------------------
curl http://192.168.1.91/control?cmd=lcd,3,9,ALARM
curl http://192.168.1.91/control?cmd=lcd,4,6,DEACTIVATED!

Nothing is displayed… single commands work but multiple don’t…

Do you have a solution ?

Thank you !!

What u mean exactly?

Sorry to be not clear, I start again:

My shell_command:

test: sh /config/shell_scripts/test.sh

my shell_script:

curl http://192.168.1.91/control?cmd=lcdcmd,clear
curl http://192.168.1.91/control?cmd=lcd,1,5,ALARM-SYSTEM
curl http://192.168.1.91/control?cmd=lcd,2,1,--------------------
curl http://192.168.1.91/control?cmd=lcd,3,9,ALARM
curl http://192.168.1.91/control?cmd=lcd,4,6,DEACTIVATED!

When I try to launch the shell_command in Home Assistant:

I’m waiting to see the screen full of writing. But nothing is displayed on the screen…

PS: Of course I changed the IP with my own :wink:

Could you please provide logs? If not turn on shell commands debug logs

Error running command: sh /config/shell_scripts/test.sh, return code: 2

I think to remember that this is due to not reachable or user rights… don’t remember really but could you check owner of your test.sh script …just be the same like home Assistant user and must be chmod +x