Method to import value from Home assistant

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
peces
New user
Posts: 7
Joined: 22 Feb 2018, 22:51

Method to import value from Home assistant

#1 Post by peces » 23 Oct 2023, 11:39

Hi all,

I would like to know how to import things ( at least booleans ) from Home Assistant to Espeasy so that some local actions can depend on them.
The Mqtt import plugin does not really suits my need for 2 reasons since (if i'm correct) :
-the MQTT message has to be published for the plugin to receive its thing (and so, espeasy does not get the value on a fresh boot)
-it is said that high-trafic topics will cause quite some load on the ESP and I don't want to risk that.

So would there be any more straightfw method so that espeasy asks Home assistant when needed : " what is the value of this boolean " for exemple at boot time and then deal with it.

Thanks for great work.

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

Re: Method to import value from Home assistant

#2 Post by Ath » 23 Oct 2023, 11:59

peces wrote: 23 Oct 2023, 11:39 The Mqtt import plugin does not really suits my need for 2 reasons since (if i'm correct) :
-the MQTT message has to be published for the plugin to receive its thing (and so, espeasy does not get the value on a fresh boot)
-it is said that high-trafic topics will cause quite some load on the ESP and I don't want to risk that.

So would there be any more straightfw method so that espeasy asks Home assistant when needed : " what is the value of this boolean " for exemple at boot time and then deal with it.
MQTT is not a Push/Pull system for transferring messages, but a Publish and Subscribe system (that's maybe a subtle difference), nicely described on this HiveMQ page

Once you have the Retain option enabled for a topic (on the server/broker), the last value will be (re)published to the subscriber (=ESPEasy) when subscribing to the topic.

By making that subscription topic as specific as possible, you will only receive the messages for that topic (or topic-group), so the MQTT Import plugin is very well suited for this task :)

Using the Mapping feature you can convert the true/false values to a 1/0 (or similar) numeric value, so ESPEasy can process that nicely, f.e. from Rules. ;)

Edit:
The same principle goes for the Subscribe topic in the Controller settings, if you don't need to receive other data or commands from that server, set it to a non-existing, or very low traffic, topic, so it won't overload the ESP.
/Ton (PayPal.me)

peces
New user
Posts: 7
Joined: 22 Feb 2018, 22:51

Re: Method to import value from Home assistant

#3 Post by peces » 24 Oct 2023, 14:56

Well, that's the perfect answer, thank you !

Adding " retain: true" into my home assistant mqtt.yaml config file + activating the retain options in espeasy controller tab did the trict.

Now the MQTT import plugin value is updated as soon as espeasy boots up and connects to broker.

Thanks again

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

Re: Method to import value from Home assistant

#4 Post by Ath » 24 Oct 2023, 15:03

Great, thanks for the update :D
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests