Blockly events and an unsolvable algorithmic problem

Moderator: leecollings

Post Reply
elgarne
Posts: 36
Joined: Monday 26 May 2014 14:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Blockly events and an unsolvable algorithmic problem

Post by elgarne »

Hi,

Because there is no multiple-state switches, I decided to create three switches to my heater:
  1. Eco
  2. Confort
  3. Off
Each off them calls a bash script that sets the state associated state.
I'd like to have two virtual ON/OFF switches, for Eco and Confort and another Off switch for the off action.
I'd like them to behave as follows:
  1. Eco
    • On: switches ON the Eco and switches OFF the Confort (eventually only if this latter is On)
    • Off: switches OFF the Eco
  2. Confort
    • On: switches ON the Confort and switches OFF the Eco (eventually only if this latter is On)
    • Off: switches OFF the Confort (eventually only if this latter is On)
  3. Off
    • Off: switches off both of them
I wanted to used blockly events but, if Eco is On and then I switch on Confort, then this latter will switch off Eco which will switch off the heater.
I cannot find any way to do it, even with variables.
It would be possible if I could add an "If" statement in the "else if" statement but that does not seem possible.
If you have any idea to help me, please, do not hesitate.
User avatar
jcjames13009
Posts: 33
Joined: Monday 09 March 2015 15:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: France / Marseille
Contact:

Re: Blockly events and an unsolvable algorithmic problem

Post by jcjames13009 »

Hi

Here is what I did for mine and it works
Capture d’écran 2015-12-10 à 21.47.25.png
Capture d’écran 2015-12-10 à 21.47.25.png (108.76 KiB) Viewed 1861 times
Modes are managed through lua script.

Where
"Chauffage sdb 1er" is your "Off" switch
"Chauffage seb Eco" is your "Eco" switch
"Chauffage seb Confort" is your "Confort" switch

Hope it'll help

JC
elgarne
Posts: 36
Joined: Monday 26 May 2014 14:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly events and an unsolvable algorithmic problem

Post by elgarne »

Merci JC.
You confirm that:
  • these are three On/Off switches?
  • you turn the "1er" switch to On when you switch On the two others?
  • you have only this blockly event for you bathroom?
Thanks again.

Edit:
I See two issues:
  • I have to switch off the heater with the off button. Actually, I wanted to switch it off when turning off the one of Eco or Confort which is on.
  • I cannot have two "else if" statements in my version of domoticz (v2.3568).
User avatar
jcjames13009
Posts: 33
Joined: Monday 09 March 2015 15:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: France / Marseille
Contact:

Re: Blockly events and an unsolvable algorithmic problem

Post by jcjames13009 »

Hi elgarne

Yes there are on/off switches.

Blocky does the following:

When Heating switch is switched Off, Eco and Confort switches are switched Off -> Heating off
When Eco switch is switched On, Heating switch is switched On and Confort is switched Off -> Heating running in Eco mode
When Confort switch is switched On, Heating switch is switched On and Eco is switched Off -> -> Heating running in Confort mode

Yes I use it only for the bathroom (Additional heating). The rest of the house is controlled by an other heating system.

As I said, I used a lua script to manage heating on & off, Eco and Confort mode with a temperature sensor and Domoticz thermostat.

Code: Select all

-- script_device_ChauffageSdB1er.lua
-- Ce script permet de gérer la température dans la salle de bain du 1er étage en fonction de la température de consigne et du mode Confort et Eco
-- Les modes Confort, Eco et Arret sont gérés à partir de 3 intérupteurs virtuels
-- La température est mesurée par une sonde Oregon Scientific
-- La température de consigne du mode Confort est gérée par un thermostat virtuel
-- La température de consigne du mode Eco est calculée à partir de la consigne Confort moins la valeur de la varialble DifConsigne 
-- Pour éviter que le chauffage ne s'allume et ne s'éteigne sans arrêt, la régulation se fait à l'aide d'un hysteresis. La mise en route du chauffage se produit dès que la température est inférieure à la consigne moins l’hystérésis et il s’éteint dès que la température dépasse la consigne plus l’hystérésis. Cette valeur devra être ajustée en fonction de la précision de la sonde de température (Hystérésis supérieur ou égal à la précision)

-- Variables
local Sonde = 'T et H SdB 1er'					-- Sonde de temperature
local Confort = 'Chauffage SdB 1er Confort'		-- Switch virtuel chauffage mode Confort
local Eco = 'Chauffage SdB 1er Eco'				-- Switch virtuel chauffage mode Eco
local FilPilote1 = 'FP SdB 1er S1'				-- Commande fil pilote Arret (1/2 alternance positive)
local Thermostat = 'SdB 1er'					-- Thermostat virtuel
local Hysteresis = tonumber(uservariables['Hysteresis SdB 1er']) -- Hysteresis
local DifConsigne = tonumber(uservariables['Dif Consigne SdB 1er']) -- Difference consigne entre Confort et Eco
-- local Hysteresis = 0.5							-- Hysteresis
-- local DifConsigne = 3							-- Difference consigne entre Confort et Eco

commandArray = {}
-- Regulation du chauffage
if (devicechanged[Sonde] or devicechanged[Confort] or devicechanged[Eco]) then
	--print ('Gestion chauffage SdB 1er')														-- Debug
	sTemp1, sHumidity1, sHumidityStat1 = otherdevices_svalues[Sonde]:match("([^;]+);([^;]+);([^;]+)")
	--print ('-- Temperature SdB 1er = ' .. sTemp1 .. '°C')										-- Debug
	sConsigne = otherdevices_svalues[Thermostat]:match("([^;]+)")
	--print ('-- Consigne thermostat = ' .. sConsigne .. '°C')									-- Debug
    -- Regulation active si mode Confort ou Eco actif
    if (otherdevices[Confort] == 'On') then
        --print('-- Gestion mode Confort')														-- Debug
    	if (tonumber(sTemp1) > (tonumber(sConsigne) + Hysteresis)) then
            --print('-- Arrêt chauffage')														-- Debug
            if otherdevices[FilPilote1] ~= 'On' then commandArray[FilPilote1] = 'On' end		-- Arrêt chauffage
			else if (tonumber(sTemp1) < (tonumber(sConsigne) - Hysteresis)) then
				--print('-- Mise en marche chauffage')											-- Debug
				if otherdevices[FilPilote1] ~= 'Off' then commandArray[FilPilote1] = 'Off' end	-- Marche chauffage
			end
		end
		else if (otherdevices[Eco] == 'On') then
			--print('-- Gestion mode Eco')															-- Debug
			if (tonumber(sTemp1) > (tonumber(sConsigne) - DifConsigne + Hysteresis)) then
				--print('-- Arrêt chauffage')														-- Debug
				if otherdevices[FilPilote1] ~= 'On' then commandArray[FilPilote1] = 'On' end		-- Arrêt chauffage
				else if (tonumber(sTemp1) < (tonumber(sConsigne) - DifConsigne - Hysteresis)) then
					--print('-- Mise en marche chauffage')											-- Debug
					if otherdevices[FilPilote1] ~= 'Off' then commandArray[FilPilote1] = 'Off' end	-- Marche chauffage
				end
			end
	    end
    end
end

return commandArray
Here is a copy, Sorry for non French Domoticz's fans. If needed I can do foreign english translation.

JC
elgarne
Posts: 36
Joined: Monday 26 May 2014 14:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly events and an unsolvable algorithmic problem

Post by elgarne »

Thanks again JC. I did not pay attention to your sentence about Lua script in your first answer.
User avatar
jcjames13009
Posts: 33
Joined: Monday 09 March 2015 15:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: France / Marseille
Contact:

Re: Blockly events and an unsolvable algorithmic problem

Post by jcjames13009 »

I forgot to tell that I use "Planning" feature to schedule Confort, Eco and Off modes.
;)
JC
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest