Seting variable on dummy device from Homey

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
MagTer
Normal user
Posts: 15
Joined: 14 Aug 2022, 22:16
Location: Sweden

Seting variable on dummy device from Homey

#1 Post by MagTer » 11 Jul 2023, 15:44

Hello everyone,

I just ordered a couple of LCD1602 I2C displays from Aliexpress with the intention of showing local sensor data in a custom-printed case with a Lolin S2 Mini.

I am using a Homey as the heart of my home automation and getting data into Homey from ESPEasy is quite simple with the ESPEasy app for Homey. My question is based on that It would be nice to show remote Homey data in the display, as well. However, I can't find much information when searching for how to send data back to the ESP from Homey.

Does anyone have any experience with this?

I read that there might be one option via MQTT and possibly one via HTTP requests from the ESP but what is the solution with as little increase as possible of the amount of grey hair? :)

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Seting variable on dummy device from Homey

#2 Post by TD-er » 11 Jul 2023, 15:49

I don't know what Homey can do regarding making HTTP calls or sending data to some topics via MQTT.

I think sending data to some MQTT topics is by far the most elegant way as you don't need to construct specific URLs to be called to show some text on the display on ESPEasy.

Then you can use MQTT Import in ESPEasy to read those values from the MQTT topics and show them on the display.

MagTer
Normal user
Posts: 15
Joined: 14 Aug 2022, 22:16
Location: Sweden

Re: Seting variable on dummy device from Homey

#3 Post by MagTer » 11 Jul 2023, 16:30

Homey can easily make outgoing HTTP calls with sensor data as query string parameters. Inbound calls to extract sensor data seem to be a bit more tricky.

Regarding MQTT, there are packages for installing a local server and a client on Homey but I currently don't have those installed.
So, If I install those components and configure MQTT-Import devices in ESPEasy, the MQTT data would be available as variables that I can show on the display?

Sounds doable but before I do that I would like to make sure that there is no option in ESPEasy to populate a variable with some dummy device via outgoing HTTP request from Homey.
That would be a few minutes of configuring a flow in Homey with an outgoing HTTP request card rather than a few hours of getting an MQTT setup configured and running smoothly.

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Seting variable on dummy device from Homey

#4 Post by Ath » 11 Jul 2023, 17:13

Best solution would be to create a rule that accepts multiple arguments, so it can 'distribute/dispatch' the values locally:

Code: Select all

on HandleArguments do // Define your own argument order
  TaskValueSet,DummyTask,value1,%eventvalue1%
  TaskValueSet,DummyTask,value2,%eventvalue2%
  TaskValueSet,DummyTask2,value1,%eventvalue3%
  TaskValueSet,DummyTask2,value2,%eventvalue4%
endon
The names can be whatever you want, tasknames must be unique, and valuenames unique within a task.
You can use the values, with optional formatting using [DummyTask#value1] (Formatting options: https://espeasy.readthedocs.io/en/lates ... red-values)

From Homey you can send http://ip.of.your.esp/control?cmd=event ... 1>,<value2>,...
If a value contains spaces or a comma, wrap that argument in quotes.

(Edit: Updated ESP url, adding /control)
Last edited by Ath on 12 Jul 2023, 11:36, edited 1 time in total.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Seting variable on dummy device from Homey

#5 Post by TD-er » 11 Jul 2023, 21:32

Just one more tip, you can test those commands/events via the command input line on the Tools page.
After entering such a command, the page will reload and the full URL for that specific command will be shown in the browser's URL field.
This will make it much easier to see where special formatting may be required.

MagTer
Normal user
Posts: 15
Joined: 14 Aug 2022, 22:16
Location: Sweden

Re: Seting variable on dummy device from Homey

#6 Post by MagTer » 12 Jul 2023, 10:37

Thanks for the replies. Appreciate the help!

I tried it this morning and the solution I got working did not use the rules. Just a direct call to TaskValueSet.
Please let me know if this is not a good option.

For those on the same quest later. What I did in Homey was to create a flow triggered by a sensor value change and then the standard Homey "Make HTTP request" found under the category Logic.

For testing purposes, I created a device of type "Generic - Dummy Device" and named it DummyDeviceName.
In the settings of that device, I created a value to store my data, called DummyValueName

The URL that worked for me was this, where the comma signs were replaced with %2C
http://192.168.5.5/control?cmd=TaskValu ... Name%2C123

Replace the IP with the one of your ESP board.

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Seting variable on dummy device from Homey

#7 Post by Ath » 12 Jul 2023, 11:33

MagTer wrote: 12 Jul 2023, 10:37 I tried it this morning and the solution I got working did not use the rules. Just a direct call to TaskValueSet.
Please let me know if this is not a good option.
Well, the advantage of using a rule is to make it more flexible and less ESP-specific, if you want to re-use that url for another device, then it will need to have exactly the same dummy device configuration, and, maybe even more important, it can handle multiple values in one call that can be applied to different destinations, that's why I called it a dispatcher. Now you only have to implement that rule on each device, and it can do/use whatever is appropriate 8-).

Comma's being replaced by %2C is just simple url-encoding, applied by Homey.
/Ton (PayPal.me)

MagTer
Normal user
Posts: 15
Joined: 14 Aug 2022, 22:16
Location: Sweden

Re: Seting variable on dummy device from Homey

#8 Post by MagTer » 12 Jul 2023, 11:47

Thanks for the feedback Ath. I will keep this in mind for when the number of ESPs grows :)

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Seting variable on dummy device from Homey

#9 Post by TD-er » 12 Jul 2023, 13:17

MagTer wrote: 12 Jul 2023, 11:47 Thanks for the feedback Ath. I will keep this in mind for when the number of ESPs grows :)
Good to use "when" here and not "if" ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests