Can I upload a data file (not an OTA update) through the ESPHome web server component?

I’m not talking about OTA updates, so when I talk about uploading, that’s not what I mean. I also am working on making this system work separately from HA, although it will be able to be integrated with HA eventually.

The bigger picture is that I’m working on a device that would be an LCD display that will go outside my workshop. I want it to show different displays depending on what what equipment is on. For instance, “Wear safety goggles. Laser is on,” or, “Do not disturb until light goes off,” or, “CNC active, enter with caution.” I don’t know how many messages or conditions I want it to check, but each condition will have an accompanying message. For instance:

Type________Entity__State_Message
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Binary_Sensor Switch1 true CNC active, enter with caution
Binary_Sensor Switch3 true Use safety goggles. Laser is on
Binary_Sensor Switch4 true Do not enter until light is off

I might also include something with each message to define the font color and background color. Also, I’m thinking, in the long run, a display like this might be useful for displaying other information, so I might add a field for each message that would include the URL to get the status of an entity, as well. I haven’t used Java in a long time, but I can think of this list as something like a Vector, where I can add more items as needed.

I’m having trouble imagining how to do this in YAML for ESPHome. I’m wondering if I could have a configuration in a file that I could somehow, whenever I modify it, upload it to my ESPHome device. Is there a way to upload a file like this so ESPHome can take it, store it, and parse it when needed? I’m having trouble understanding how a structure like this could be handled in YAML, especially if it would be expandable, to add more messages accompanying more devices over time.

Is there some way I can either upload a file with info like this in it, or some way I can do this in ESPHome, with a YAML file?

I’d probably go the other way around, and have ESPhome download a file from somewhere.

I’m finding a nightmare with HTTP Request, that I’ve posted about. The domain setting does not seem to work at all. No matter what I have to specify the full LAN domain (I use a full domain name system in my LAN, so the machine scarecrow, for example, can be reached at scarecrow.emeraldcity.oz. On every other computer on my LAN, it searches emeraldcity.oz first, before saying a system is unreachable, but not ESPHome. With or without domain set (and the docs on that setting are not clear), it can’t reach a system just by name. I also cannot reach external websites at all - I always get a connection refused error.

If I could get HTTP Request working as it should, I’d still have the issue of having to have a web server somewhere on my LAN. I already have a few friends interested in this project, but many of them don’t have that on their LAN. I’m trying to do as simple and as “low knowledge” a solution as I can so I won’t have to be helping all by friends who want to use this.

Create the messages in home assistant. Put them in a text helper. Use the HA text entity in esphome and print it. Same with color, font etc

It sounds like you need a few predefined strings and a way to switch between them.
As I understand you don’t have a sensor on the CNC that the ESP can determine this by itself?

So why about a rotary knob to switch between the different messages?
That should be the easiest way. Or do you need to be able to do it remotely (a few meters from the display)?

Is this something I do with HA as part of the setup, so I can setup the messages to be usd (or maybe even images?), and then it’s transferred from HA to the ESP system? Or is this something I do as part of the setup to use HA to control it? As I mentioned, I want this working separately from HA. I’m finding that at least once or twice a year (at least), I do an update/upgrade on HA and it breaks at least one integration. I don’t want systems in my workshop to be down for a few days, or harder to use, because of that.

I’ve thought of that, but, at this point, I’m now designing something I’ll use and that friends are interested in. I want it to be possible for people to change the messages at will. So I don’t want just one predefined set. Right now I’m thinking I might limit it to 8 or 10. Each one can be left blank or could be user-defined to include a url to check for status info in JSON, the state to match, and the message to display. (I might also be able to include the background and font colors.)

While I’m using ESPHome on the control board and for PWM signals to control some vent fans, I’m thinking this particular function might not be a good match for ESPHome. I’m not sure yet. It’s turning out that something I thought would be easy to setup is much more complex than I expected.

I am making a control board for the CNC and associated systems. This board will have switches and sensors, all binary. The board runs ESPHome and can detect when a switch is on or off or, in some cases, through an optocoupler, will just sense if a device is on or off. So that device, with ESPHome, will know if the CNC or laser, laser driver, or anything else with the CNC system, is on or off. (And eventually I think I’l lbe using a control board like this for other things, too.)

That’s an interesting idea. Remember, this status sign and the control board are two different devices. I didn’t mention it, but I’ve been thinking the sign could respond to multiple devices and I could prioritize messages, so it goes with the most important status message if two or more might fit the criteria. But the issue is that I’d like to make it relatively easy to change the messages and to add more messages if needed. I realize this could be done with HA, but, as mentioned above, HA updates break things. I’ve had to limit myself to only updating HA 2-3 times a year, since I can’t afford the downtime and my “fix it” time more than that if an update breaks an integration.

What about you use the webserver and have a template text that you can enter strings in.
The strings could perhaps be ; delimited and the rotary encoder (knob) increments or decrements a number entity.

Then something equivalent to this in ESP-Home:

{% set string = "Wear safety goggles. Laser is on,Do not disturb until light goes off;CNC active, enter with caution." %} 

{% set knob = 10 %}

{{ string.split(";")[knob % (string.split(";") | count)] }}  // Do not disturb until light goes off

This means you need to open the IP of the device and you get something like this:
web_server-v2.png (1900×1271)

The entity template number has a “text box”, the same as template text.

I have a lot of ideas in my head, now, and many because of this thread. Some came up directly, others in response to, “That will cause this kind of problem, but solving it that problem this way…”

I’ve thought about a webserver, but I also know people who use Home Assistant or would like this, who won’t get how to set up a webserver, which would lead to them not liking it, or maybe reading a website somewhere about how to set one up and end up making security holes on their workstation. This is leading me to several other possible solutions:

  1. Do the sign with a Pi. I can minimize whatever is on it. Problems: A) a Pi has a full OS on it (to do what I need, it would), which means more updates and more running at once and sometimes other programs can get in the way and gum up response time. B) I want this to work directly with the ESPHome systems or with HA. That means the need to use mDNS on a Pi, learning that, writing the webpage (last time I did that was before AJAX existed - long time!), and figuring out how to interface with HA (eventually).

  2. Set up a simple web server on a Pi. While it’s not necessary for me, some friends that want this could use it. Not too hard, still have to write the webpage, but it could read a config file and push it to the device using REST. There’s a few other device ideas I have and this could help with them, or it could be a central place to handle configurations like this for multiple signs. But that seems to be thinking too big and being overly optimistic that I’d be doing a lot more like this.

  3. I’m wondering if it’s possible to put a Pi Zero and an ESPHome in the same box and let them talk to each other via a serial connection. If that worked, then, maybe, data could be managed so only what is needed is sent to the ESPHome setup.

  4. I don’t see how I can do an array of variables in anything I’ve found in ESPHome. Maybe I could do 8 possible messages. That would give me a limited number to work with, so I could do 8 Number Templates (for ranking messages in importance). There would also be 8 Text Templates for URLs to check for JSON data, 8 more for the setting to check, 8 more for the setting value to match, and 8 more for the messages. Without being able to loop through an array, that’s a lot of repeated code, but it works. It’s the least flexible and extensible option for this, but it works and I can get it going and come back to it later if I have reason to do more with this.

#1-#3 are both a lot of work, but I’m finding learning YAML and the API is pretty involved as well - and some features don’t always seem to work. For instance, I’ve tried set_name() for a Binary Sensor and it never seemed to behave properly. (I’m finally starting to think of YAML as, basically, a limited OOP language where I can use lambdas for functions YAML doesn’t provide.)

Also, one other point about a knob: That’s not really going to work, since I want to be able to listen to or examine multiple devices for states and have a different message for each one. For instance, a message for if the laser is on, if the CNC is on but the laser is off, if both are off, but for less than 5 minutes (since I might restart), and maybe even a “prep” message, so when I’m about to start, I can flip a switch to say, “Laser or CNC about to be in use…”


EDITED to add:

  • Sorry for being longwinded, but I’m finding it helps me think through a problem and sometimes posting other options leads to people making good suggestions that work for me.

  • Since I wrote this, I realized I had not searched for arrays in ESPHome. Apparently it can do them, but I don’t see how I can create an array of Text Templates. Is it possible to have arrays of Text Templates and Number Templates? That would give me a good start on this.

There is a built in web server you can use in ESP-Home. Why would anyone need to “set up a webserver”?
If they have HA then there is no need for the webserver, but you said before this was for people who don’t have HA.

You don’t need an array, a string that is delimited is pretty much the same thing as an array.

Your #4 is just confusing.
What URLs? What JSON?

And why even talk about a pie when everything is so much easier with a ESP?

I may have conflated some posts and put things together in my head, so I didn’t read your post correctly - which is part of a reading issue I have. (I used to teach special ed - at one point I could have explained that issue in boring detail, now I can’t even remember much more than that it’s a pain to deal with sometimes.)

if I’m having ESPHome reading the settings from another computer.

That would be a nightmare for me to track and parse (reference the reading issue I mentioned above). But it’s a possible solution that I’m going to think over. I’d really rather find a way to create arrays of Text Templates and Number Templates. I see I can create arrays of C++ type variables, but I don’t see how I can create arrays of Templates.

(Note: Due to the reading issue, and a few other experiences, I have a habit of working hard to make sure once I have something working, a program, or hardware, to make using it and configuring it require as little tech background or “thinking” as possible - I’m really big on making things as easy to use for the user as possible. I know in 6 months I’ll forget formatting and other things, so I think in terms of making it all easy to use for my future self who has been doing enough that, in 6 months, I don’t want to have to take a while to read my own docs and figure out how it works again.)

Since I don’t want to require Home Assistant for this, the best way I can see for 2 ESPHome devices to communicate is using the REST API. So, for instance, I’d specify a URL to use to read the switch for the CNC, another for the laser - and others for any other switches or sensors to respond to.

I don’t see it as easy at all. It uses a configuration file that’s somewhere between configuration, data, and program code. I’m fighting to get a clear ability to make things work in here. I’m having multiple issues (I mentioned the set_name() not working for a binary sensor as one, I also cannot get HTTP Request to work properly, even after posting about it.) There are times I just want to write it all in Python and have it done. But I am also trying to learn ESPHome because I see a LOT of potential in it for projects I want to do.