Blockly: Store current dimmer level in user variable?

Moderator: leecollings

Post Reply
david81
Posts: 6
Joined: Thursday 31 December 2015 2:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Blockly: Store current dimmer level in user variable?

Post by david81 »

So, I'm just getting my feet wet with Blockly (coming from a coding background, it seems pretty straightforward). One thing that I'm hoping I'm missing is the ability to store the current level of a dimmer in a user variable. Basically, I'm trying to create a dimmer preset dummy switch that allows me to easily set a light to a certain level with a single click but to store the "previous" value is a user variable for when the preset is then turned off. Using the dimmer switch block as the "value" for the Blockly Set block just seems to write "device[3]" to the variable, instead of the actual value. Is this expected behavior?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Blockly: Store current dimmer level in user variable?

Post by Egregius »

If you have a coding background, why use blockly then?
Try lua/bash/php, endless possibilities.
In php I would store that value in a memcache variable.
madrian
Posts: 231
Joined: Saturday 27 August 2016 1:18
Target OS: -
Domoticz version:
Contact:

Re: Blockly: Store current dimmer level in user variable?

Post by madrian »

Is there any way to store Dimmer status before it turns off / or get current value if turned on?

I wrote this code to test it:

Code: Select all

commandArray = {}
if devicechanged['hello'] then
    print (otherdevices_svalues['hello']);
  end
if(devicechanged['hello']=='Off') then 
        print (otherdevices_svalues['hello']);
    elseif(devicechanged['hello']=='On') then  
         print (otherdevices_svalues['hello']);
end        
 
return commandArray
The result in both case is 0, so it's unable to get the actual value.

Any ideas?
madrian
Posts: 231
Joined: Saturday 27 August 2016 1:18
Target OS: -
Domoticz version:
Contact:

Re: Blockly: Store current dimmer level in user variable?

Post by madrian »

Any ideas? :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest