Page 1 of 3

Math operators and Blocking

Posted: Monday 02 February 2015 19:49
by juankar
I've seen in clcky there is no math operators like add, multiply, substract and so.
Because of that we can compare, for example, actual time with sun rise or sunset, but we cannot compare with 1 horu after sunrise or X tima before sunset
I mean:
If I want a trigger at sunrise I use an IF block
if time >= sunrise
do set light = OFF

But if I want to trigger x minutes or hour after sunrise I'de do

IF time >= sunrise + 1hour
DO set light = OFF

With actual blocky I can't do these kind of actions.
Another situation is the use of counter....

Any idea? or the only way is to use scripts?

(I know that I can use timers for simple switches actions, but I'm speaking about more complex situations, and without using scripts)
Thanks

Re: Math operators and Blocking

Posted: Monday 02 February 2015 19:51
by ThinkPad
I think you will need Lua scripting for that.

Re: Math operators and Blocking

Posted: Monday 02 February 2015 20:01
by Domosapiens
I vote for Subtract and Add in Blockly.
And with a result that also can be written to a Dummy Sensor.

A necessity for deltaT calculation and hysteresis setting in heating solutions.
Hope the development team can find some time ...
Regards
Domosapiens

Re: Math operators and Blocking

Posted: Monday 02 February 2015 22:27
by Grumly
In your switch configuration menu you can schedule On/Off and compare +/- minutes before or after sunrise (sunset). Sorry for the translation I'm using the french version

Re: Math operators and Blocking

Posted: Tuesday 03 February 2015 6:06
by mongoose
Yes you could change a dummy switch to go on or off before sunset/rise and then use that in blocky for more complex operations or check out how to do it in lua script...

Re: Math operators and Blocking

Posted: Tuesday 03 February 2015 19:37
by juankar
Very clever
mongoose wrote:Yes you could change a dummy switch to go on or off before sunset/rise and then use that in blocky for more complex operations or check out how to do it in lua script...
That is an elegant solution!!! I'll try it

Thanks

Re: Math operators and Blocking

Posted: Wednesday 17 June 2015 17:08
by ewezel
I also want to use math operators in blockly. I want to calculate a DeltaHumidity: the difference between the outside humidity (from a weather station nearby) and the humidity in my bathroom. This to switch my ventilation. ANy clue how to do that in Blockly?

Re: Math operators and Blocking

Posted: Wednesday 17 June 2015 22:22
by jake
ewezel wrote:I also want to use math operators in blockly. I want to calculate a DeltaHumidity: the difference between the outside humidity (from a weather station nearby) and the humidity in my bathroom. This to switch my ventilation. ANy clue how to do that in Blockly?
I have no solution for you, but just wondering if you are trying to do the right thing. Relative humidity is relative to the temperature. You need to calculate back to 1 temperature for both sensor results to do a correct comparison

Re: Math operators and Blocking

Posted: Thursday 18 June 2015 16:46
by ewezel
jake wrote:
ewezel wrote:I also want to use math operators in blockly. I want to calculate a DeltaHumidity: the difference between the outside humidity (from a weather station nearby) and the humidity in my bathroom. This to switch my ventilation. ANy clue how to do that in Blockly?
I have no solution for you, but just wondering if you are trying to do the right thing. Relative humidity is relative to the temperature. You need to calculate back to 1 temperature for both sensor results to do a correct comparison
I want to switch on the ventilator if the internal humidity is more than 10% higher than the outside humidity. I do not care about the temperature. Normally the difference between the in house humidity and the outside humidity is 2 or 3%.

Re: Math operators and Blocking

Posted: Thursday 18 June 2015 18:47
by jake
I understand that you don't care about temperature, but it is called relative humidity for a reason. When it is cold outside, the relative humidity can be sky high, but the air can still be very useful to dry your humid bath room. When comparing humidity between two environments, you n need to recalculate to 1 temperature to make sense. RH itself is only a percentage, see Wikipedia

But, on topic, I don't think you can succeed with blockly, only when you want to act on equal, smaller or bigger values.

Re: Math operators and Blocking

Posted: Friday 20 May 2016 12:42
by ebretteville
Hye everybody,
Its strange as blockly is supporting natively the maths and loops operation as seen on there website: https://developers.google.com/blockly/
and on this screenshot:
Image
Any ideas how to activate this two missing "library"?

Re: Math operators and Blocking

Posted: Friday 20 May 2016 16:59
by juankar
Interesting, I'd like this option too.!!

Re: Math operators and Blocking

Posted: Thursday 04 August 2016 15:34
by saintman
+1

Re: Math operators and Blocking

Posted: Thursday 04 August 2016 16:54
by juankar
After I worked deeper with Blockly, I think that it needs more that just mathematic operators. In my opinion Blockly is far awway from Lua scripts. Perhaps if a trnaslator to Lua were added to the Blockly editor.
Blockly is poerful, but it's just an editor. For more you can see https://developers.google.com/blockly/g ... tarted/web

Re: Math operators and Blocking

Posted: Monday 14 November 2016 11:06
by tommit01
Now Blockly has a LUA translator/generator..

I think now only reference to C++ has to be realized

see here:
https://blockly-demo.appspot.com/static ... index.html

BR
Tommit

Re: Math operators and Blocking

Posted: Wednesday 17 May 2017 18:40
by videobelu
No news about Math functions implementation ???

Thanks

Re: Math operators and Blocking

Posted: Thursday 17 August 2017 9:25
by ebretteville
+1

Re: Math operators and Blocking

Posted: Saturday 21 October 2017 15:05
by ebretteville
I think I got it working. Will post later but Image

Sent from my MI MAX using Tapatalk


Re: Math operators and Blocking

Posted: Friday 10 November 2017 6:21
by Mesomorf
ebretteville wrote: Saturday 21 October 2017 15:05 I think I got it working.
Please! Can you PM me what files you moddified in Domoticz to get open up math? I tried myself and found some references in the www folder but without success.

Re: Math operators and Blocking

Posted: Sunday 12 November 2017 16:33
by ebretteville
Just change the file toolbox.xml file. It's attached