Math operators and Blocking

Moderator: leecollings

juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Math operators and Blocking

Post 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
ThinkPad
Posts: 890
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 »

I think you will need Lua scripting for that.
I am not active on this forum anymore.
User avatar
Domosapiens
Posts: 232
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 »

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: 1
Joined: Sunday 25 January 2015 2:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Math operators and Blocking

Post 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
User avatar
mongoose
Posts: 42
Joined: Friday 22 November 2013 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Math operators and Blocking

Post 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...
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Math operators and Blocking

Post 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
ewezel
Posts: 2
Joined: Monday 13 April 2015 10:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Math operators and Blocking

Post 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?
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: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Math operators and Blocking

Post 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
ewezel
Posts: 2
Joined: Monday 13 April 2015 10:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Math operators and Blocking

Post 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%.
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: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Math operators and Blocking

Post 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.
ebretteville
Posts: 39
Joined: Sunday 10 January 2016 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post 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"?
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Math operators and Blocking

Post by juankar »

Interesting, I'd like this option too.!!
saintman
Posts: 4
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 »

+1
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Math operators and Blocking

Post 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
User avatar
tommit01
Posts: 39
Joined: Friday 12 July 2013 14:08
Target OS: Raspberry Pi / ODroid
Domoticz version: multiple
Location: Germany / SL
Contact:

Re: Math operators and Blocking

Post 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
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: 5
Joined: Monday 07 March 2016 21:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Math operators and Blocking

Post by videobelu »

No news about Math functions implementation ???

Thanks
ebretteville
Posts: 39
Joined: Sunday 10 January 2016 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville »

+1
ebretteville
Posts: 39
Joined: Sunday 10 January 2016 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville »

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

Sent from my MI MAX using Tapatalk

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

Re: Math operators and Blocking

Post 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.
ebretteville
Posts: 39
Joined: Sunday 10 January 2016 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Cherbourg - Caen | France
Contact:

Re: Math operators and Blocking

Post by ebretteville »

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

Who is online

Users browsing this forum: No registered users and 1 guest