MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
nuiler
New user
Posts: 4
Joined: 04 May 2023, 11:47

MQTT

#1 Post by nuiler » 26 May 2023, 07:31

MQTT point in comma

How can I convert a value 0.18234 to 0.18234 so that I can calculate with it?

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

Re: MQTT

#2 Post by TD-er » 26 May 2023, 09:00

I think you meant "0,18234" as input?
Where do you get this value from?
Is it via MQTT import or via commands and using C005?

nuiler
New user
Posts: 4
Joined: 04 May 2023, 11:47

Re: MQTT

#3 Post by nuiler » 26 May 2023, 09:15

I get the value via Generic - MQTT import.

What means via commands and using C005.

Can I change the dot to a comma

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

Re: MQTT

#4 Post by TD-er » 26 May 2023, 09:41

C005 is the OpenHab/HomeAssistant controller in ESPEasy.

As shown in its documentation, you can also subscribe to topics crafted in such a way that they represent commands for ESPEasy. See: https://espeasy.readthedocs.io/en/lates ... d-handling

As you can also craft commands to generate an event, and the comma is the separator of parameters (called eventvalues in ESPEasy), you could combine those separate eventvalues into a single value.

Ton does have a lot of work recently on the MQTT import plugin, which he also documents very well: https://espeasy.readthedocs.io/en/lates ... #p037-page

I did have a quick look, but right now I can't think of a way how to replace those decimal commas.
Maybe he has some idea...

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

Re: MQTT

#5 Post by Ath » 26 May 2023, 10:07

Best idea so far is to change it at the source, as we are expecting US/Intl. formatted decimal numbers, not localized decimal numbers.
/Ton (PayPal.me)

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

Re: MQTT

#6 Post by Ath » 26 May 2023, 20:13

It turned out to be quite easy, just enable the 'Generate events for accepted topics' option in the MQTT Import task and add a rule for your MQTT topic to 'convert' and assign the value like this:

Code: Select all

on mqtt/topic/cmd do // Handle the MQTT Topic event from MQTT Import
  Let,1,%eventvalue1%.%eventvalue2% // The initial comma separates the values into 2 arguments
  LogEntry,'Value: %v1%' // Optional logging of the value
  TaskvalueSet,Variables,Dummy1,[var#1] // Assign the value to a Dummy task to be used elsewhere, or immediately use it somewhere else like on a display
endon
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests