Need some help with a complex rule set...

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Need some help with a complex rule set...

#1 Post by mattlward » 03 Mar 2018, 05:46

I am importing via MQTT the wind direction in degrees. I would like to take that number and display it as n,s,e or w. Eventually I will break them down even further. I have written rulesets before but this is way out of my skill set right now.

I have started with a dummy task and a set of rules. The dummy variable 1 does get the imported value from MQTT, but the ruleset never converts it to text. I see the event in the logs that does the first part and then nothing... basically anything 45 degrees of either side of a primary direction will be assigned the letter of that primary direction...

My MQTT variable is s2#Deg and I need to end up with TaskValueSet1,2,X on the display...

Here is the ruleset that I have started...

Code: Select all

On s2#Deg Do
TaskValueSet,1,1,[s2#Deg]
 If [Dummy#Deg]>315
  Event,SetToNorth
 EndIf

If [Dummy#Deg]>225
 Event,SetToWest
EndOn

If [Dummy#Deg]>135
 Event,SetToSouth
EndOn

If [Dummy#Deg]>45
 Event,SetToEase
EndOn

If [Dummy#Deg]>0
 Event,SetToNorth
EndOn

If [Dummy#Deg]=0
 Event,SetToNorth
EndOn

//Below is events

On SetToNorth Do
 TaskValueSet1,2,N
EndOn

On SetToWest Do
 TaskValueSet1,2,W
EndOn

On SetToMed Do
 TaskValueSet1,2,S
EndOn

On SetToHigh Do
 TaskValueSet1,2,E
EndOn

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Need some help with a complex rule set...

#2 Post by Domosapiens » 03 Mar 2018, 10:57

Check the pairs:
On ...EndOn
If ....EndIf
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

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

Re: Need some help with a complex rule set...

#3 Post by TD-er » 03 Mar 2018, 19:06

There is already some code for the Domoticz controller to convert degrees into 8 or 16 wind directions.
I think we could add that somewhere.
Can you make an issue for that? (on Github)

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: Need some help with a complex rule set...

#4 Post by mattlward » 04 Mar 2018, 00:21

@TD-er, I sure will.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Need some help with a complex rule set...

#5 Post by grovkillen » 09 Mar 2018, 21:34

https://www.letscontrolit.com/wiki/inde ... onversions

This is now implemented... some of the examples are not yet live for float values (the result are integer at the moment but an update is taking place as I write this).

Enjoy and a big hats off for TD-er for bringing this to the formula toolbox! :)
Last edited by grovkillen on 09 Mar 2018, 22:00, edited 1 time in total.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: Need some help with a complex rule set...

#6 Post by mattlward » 09 Mar 2018, 21:42

I must agree, it is working very well!

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

Re: Need some help with a complex rule set...

#7 Post by TD-er » 09 Mar 2018, 23:34

grovkillen wrote: 09 Mar 2018, 21:34 [...] for bringing this to the formula toolbox! :)
Not entirely for use in a formula.
A sensor can only output float values and these conversions do float (or int) to String.
This means you can still use them anywhere where you want to modify a string.
Like rules, Publish messages, OLED display, email notifications, etc.

The input for these conversions will probably be a sensor output, like "[bme#Temp]"

Post Reply

Who is online

Users browsing this forum: No registered users and 82 guests