Math operators and Blocking

juankar
Posts: 504
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Math operators and Blocking

Post by juankar » Monday 02 February 2015 20:49

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

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Math operators and Blocking

Post by ThinkPad » Monday 02 February 2015 20:51

I think you will need Lua scripting for that.
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

User avatar
Domosapiens
Posts: 371
Joined: Wednesday 20 August 2014 12:08
Target OS: Windows
Domoticz version: V3.5981
Location: NL
Contact:

Re: Math operators and Blocking

Post by Domosapiens » Monday 02 February 2015 21:01

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
Win Vista&7; 1#Aeon Z-Stick S2; 1#Aeotec Z-Sick Gen5, 6#Fib.FGBS001; 24#DS18B20; 8#Everspr.AN158-2; 3#Philio PAN04; 1#Philio PAN06, 1#YouLess El; 1#Fib.FGWPE; 1#ZME_RC2; 2#FAK_ZWS230, 2#Quib.ZMNHCDx, 1#Quib.ZMNHDD1, 7#EM6555

Grumly
Posts: 3
Joined: Sunday 25 January 2015 3:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Math operators and Blocking

Post by Grumly » Monday 02 February 2015 23:27

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

User avatar
mongoose
Posts: 89
Joined: Friday 22 November 2013 11:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Math operators and Blocking

Post by mongoose » Tuesday 03 February 2015 7:06

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...

juankar
Posts: 504
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Re: Math operators and Blocking

Post by juankar » Tuesday 03 February 2015 20:37

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

ewezel
Posts: 7
Joined: Monday 13 April 2015 10:36
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Math operators and Blocking

Post by ewezel » Wednesday 17 June 2015 17:08

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?
pi1 with Domoticz and RFXtrx433E USB reciever, 6*Switch Action (Eurodomest) Humidity/Temperature sensor Alecto WS-1700, KiKa ACM-3500-3 to switch Ventilation
Pi2 with Kodi

jake
Posts: 492
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: Math operators and Blocking

Post by jake » Wednesday 17 June 2015 22:22

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

ewezel
Posts: 7
Joined: Monday 13 April 2015 10:36
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Math operators and Blocking

Post by ewezel » Thursday 18 June 2015 16:46

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%.
pi1 with Domoticz and RFXtrx433E USB reciever, 6*Switch Action (Eurodomest) Humidity/Temperature sensor Alecto WS-1700, KiKa ACM-3500-3 to switch Ventilation
Pi2 with Kodi

jake
Posts: 492
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: Math operators and Blocking

Post by jake » Thursday 18 June 2015 18:47

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.

ebretteville
Posts: 32
Joined: Sunday 10 January 2016 15:41
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville » Friday 20 May 2016 12:42

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"?

juankar
Posts: 504
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Re: Math operators and Blocking

Post by juankar » Friday 20 May 2016 16:59

Interesting, I'd like this option too.!!

saintman
Posts: 8
Joined: Monday 20 June 2016 11:13
Target OS: NAS (Synology & others)
Domoticz version: 3.5254
Location: Moscow
Contact:

Re: Math operators and Blocking

Post by saintman » Thursday 04 August 2016 15:34

+1

juankar
Posts: 504
Joined: Saturday 30 August 2014 20:20
Target OS: Raspberry Pi
Domoticz version:
Location: Spain
Contact:

Re: Math operators and Blocking

Post by juankar » Thursday 04 August 2016 16:54

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

User avatar
tommit01
Posts: 328
Joined: Friday 12 July 2013 14:08
Target OS: Raspberry Pi
Domoticz version: multiple
Location: Germany / SL
Contact:

Re: Math operators and Blocking

Post by tommit01 » Monday 14 November 2016 12:06

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
1 x RPi3
4 x RPI
3 x RPi2
1 x RPI2 + Win 10 IoT (experimental device)
2 x RPI2 Raspbian "Jessie" + Domoticz (for tenants)
2 x RPI OSMC @ 1GHz
1 RPi Zero W + Cam NOIR
1 RPi Zero W + Cam
RFXtrx 433 FW 1015
RFXtrx 433 E FW 1020

videobelu
Posts: 6
Joined: Monday 07 March 2016 22:04
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Math operators and Blocking

Post by videobelu » Wednesday 17 May 2017 18:40

No news about Math functions implementation ???

Thanks

ebretteville
Posts: 32
Joined: Sunday 10 January 2016 15:41
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville » Thursday 17 August 2017 9:25

+1

ebretteville
Posts: 32
Joined: Sunday 10 January 2016 15:41
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville » Saturday 21 October 2017 15:05

I think I got it working. Will post later but Image

Sent from my MI MAX using Tapatalk


Mesomorf
Posts: 4
Joined: Saturday 02 April 2016 9:59
Target OS: Windows
Domoticz version:
Contact:

Re: Math operators and Blocking

Post by Mesomorf » Friday 10 November 2017 7:21

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.

ebretteville
Posts: 32
Joined: Sunday 10 January 2016 15:41
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville » Sunday 12 November 2017 17:33

Just change the file toolbox.xml file. It's attached
Attachments
toolbox.xml
(2.5 KiB) Downloaded 300 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest