Direct Shelly control from ESP32

Hi. I’m new to hhttp_requestome automation with a big learning curve ahead of me. My first project was using 2 DS1820Bs with an ESP32 development board to monitor the flow and return temperatures on my central heating boiler on HA. It works a treat! Project #2 is temperature control of a fan heater in my greenhouse. I have a Shelly 1 Plus that I want to control with a local ESP32/DS18B20. I want to avoid going through HA as it is presently running in a virtual machine on my PC, so not particularly stable. I am not familiar with the mechanics of the HTTP protocol (and even less familiar with C++) and have been unable to identify code that will operate the Shelly from the ESP32. I feel that this should be a very simle issue that many other beginners will have come across. I would be grateful if someone could explain why the following code - which validates within ESPHome - doesn’t operate the Shelly device when the URL will work using a standard browser;

  - pin: GPIO33

  - platform: dallas
    address: 0x9d3ce1e380c92628
    name: "Greenhouse temperature"
      - above: 5

Is the shelly also running esphome?

No. It’s ‘out of the box’. I thought it should be simple to control that way but perhaps this is a misconception dues to my lack of knowledge of the OTA protocol. I think I need to understand how to parse that URL and break it down into its appropriate components.

Ive had some Shelly’s forever and i didnt even realize you could do direct communication like this. I knew mqtt was an option but, this is good stuff to know too.

Speaking of mqtt, why not just use that? I realize its not device to device and needs a broker but, its a very reliable communication method also and you can run a broker on just about anything.

Two reasons really:

  1. My learning curve is already steep enough as it is. Perhaps I’ll get to MQTT eventually.
  2. The only hardware platform I have available is an old PC with ESPHome running in HA in a virtual machine. My initial idea was to communicate from the ESP32 to shelly via bluetooth to avoid dependency on my flaky PC and my WiFi, but thought that was perhaps a little too ambitious. :grin:

I’ve had a look at the http_request documentation again but I can’t find enough practical examples to figure-out how to construct the appropriate message to send to Shelly in ESPHome.

Mqtt is a really lightweight messaging protocol. There is a Mosquitto mqtt broker that you can add on to HA and then your broker is part of HA. You could also install it separately on a pc too.

Think of it like the post office. Each device will publish or subscribe to a topic and the broker makes sure the right message(publish) goes to the correct recipient(subscriber)

Mqtt isnt uncommon at all. I would plan on learning it now or later when it comes up again because it will! Its widely used in this space.

I would invest in some new hardware. The minimum requirements to run HA arent huge. Raspberry pi 4’s are available again and if you get a minimum 4gb, it is a good choice, thats what ive been using for probably 3 years now. Another budget friendly option is you can find Renewed/Refurbished HP elitedesk mini pc’s for a little over 100$ or roughy the same price as a pi4. Ive never ran HA in a VM but i did play around with Docker. By far, the most user friendly and easy do stuff in is HA OS instaed directly on the hardware.

For example i use Espresence and so do many others. Its firmware for esp32’s and you can do bluetooth room presence. You can see which devices are in what rooms and how far tbey are from the esp32 base station. That uses mqtt to establish sensors in HA. Its just one of many.

What do the logs say. Is an http request being sent or trying to be sent? In your config its only sent if a dallas sensor is above 5. If its already above 5 it wont send. The on_value is only True when its below the threshold number and then rises above it

I have to agree with @Fallingaway24. A RPI4b+ is so small, relatively cheap and does so much. I probably might go HA API as it works seamlessly in the background. It is also running my Mqtt broker. Easier to learn your away around

I mean if their pc is so unreliable and to the extent that you dont trust it at all and your seeking a way to control your Shelly’s without the Pc or HA in the event isnt working. Thats what you call a sign! Theres absolutely no reason to add any new devices to your smart home if its this bad, this unreliable and your looking for alternate ways to turn the lights on/off outside of HA. Upgrading the hardware needs to be priority number 1.

1 Like

Thanks @JulianDH and @Fallingaway24 .

  • There’s also the element of a challenge in keeping it to the 2 devices :wink:
  • I’m getting a HAGreen for my birthday next month (I expect it to ‘just work’ like my Apple devices do)
  • I’ve just come across the Shelly documentation that I’m sure will help. I’m certain now that my 40 years of URL experience using a browser have misled me into not appreciating the comms protocol

Oh nice! Ive not had the privilege to play with the HA Green but, from what i kmlw about it, its basically a high performance raspberry pi4 and has some extra bells and whistles built-in like zigbee. The only downside to the Green aeast right now is i dont believe there is much support for using it for something that isnt HA. The great thing about the Pi’s is you can turn them into all sorts of things very easily and theres lots of documentation. Now, you can probably still do those things with the green but may not be very easy.

I only meant like if you upgrade later on or you aquire a second one down the road. It likely wont be as simple to find a new purpose for it.

@Fallingaway24 I know what you mean, but I’m looking at HA as a means to an end - to support/facilitate my larger projects of PV & Battery installation and replacement of my ageing boiler with an ASHP. I was originally planning on getting a Pi but the HAGreen seemed to offer an easier route with everything working (hopefully) straight out of the box. There’s a shortage in the UK at present so imported one from Germany. I was pleased to discover it came with a mains power adapter and a UK adaptor for that.

Oh ya, i definitely understand that. Unless you plan to get deep into integrating multiple security cameras and doing all that Nasa space shuttle overkill where it can tell one dog from another dog with object detection similar to a Terminator so you know which neighbors dog is crapping in your lawn. Outside of that type of stuff, the Green should be more than capable for a long time.

For the record, i love Terminators and i dont know any John Connors so, my name doesnt need to go on any “lists”