How does the S_SCENE_CONTROLLER work?

Moderator: leecollings

Post Reply
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

How does the S_SCENE_CONTROLLER work?

Post by toreandre »

Im building a scene controller with touch modules as buttons.

Right now i have 2 buttons that is presented as S_SCENE_CONTROLLER

Code: Select all

present(CHILD_ID_3, S_SCENE_CONTROLLER); // Present button
 present(CHILD_ID_4, S_SCENE_CONTROLLER); // Present button 
I want to make each button activate a specified scene.
At first i tried to use this:

Code: Select all

MyMessage msg1(CHILD_ID_3,V_SCENE_ON); // Added message for buttons
MyMessage msg2(CHILD_ID_4,V_SCENE_ON); // Added message for buttons
I then added the node to domoticz and i got 3 devices (the node as scenecontroller and 2 devices that represent each button), i added each button as scene activators for different scenes.

The problem is that i can only activate a scene once, so i edited my sketch to use these messages:

Code: Select all

MyMessage msg1(CHILD_ID_3,V_SCENE_ON); // Added message for buttons
MyMessage msg2(CHILD_ID_4,V_SCENE_OFF); // Added message for buttons
Now i can activate the scene, but i need to use my second button to deactivate it before i can activate it again.

In domoticz its no need to deactivate scenes since turning a scene off does nothing (groups can be tuned on and off).

How do i add a V_SCENE_OFF to the same button that sends V_SCENE_ON?
User avatar
gizmocuz
Posts: 2521
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by gizmocuz »

you want the domoticz scene to be activated by both child id 3 and 4, regarding the status (on/off), i think you can add multiple activators to a scene/group
if you want to turn off a scene, that is not possible, a scene can only be activated
Otherwise, you can build an Event (blockly) to do this
Quality outlives Quantity!
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by toreandre »

I want child 3 to control scene 1 and child 4 to control scene 2.

When i connected my node to domoticz i got 3 devices, scene 1 (child 3), scene 2 (child 4) and one device called "Scene ctrl".

It seems to me that the two devices (scene 1 and 2) is controling the "scene ctrl" device on and off, and the "scene ctrl" is the one that controls the actual scene (activation device).

When i use this:

Code: Select all

MyMessage msg1(CHILD_ID_3,V_SCENE_ON); // Added message for buttons
MyMessage msg2(CHILD_ID_4,V_SCENE_ON); // Added message for buttons
I can turn on the device "Scene 1" with button 1 (child 3) and the "scene ctrl" device is automaticly turned on and my scene is also activated.
But if i push the button again nothing happens (since the device "scene 1" and "scene ctrl" is already on).
If i press the second button (child 4) nothing happens.

When i use this:

Code: Select all

MyMessage msg1(CHILD_ID_3,V_SCENE_ON); // Added message for buttons
MyMessage msg2(CHILD_ID_4,V_SCENE_OFF); // Added message for buttons
I can use button 1 (child 3) to turn on the device "scene 1" witch turns on the "scene ctrl" and activates the scene.
If i use button 2 (child 4) the device "scene ctrl" turns off and i can now use button 1 to activate my scene again.

Please let me know if i explain this in a difficult way and i will try to explain it better.
Attachments
activation device for scene
activation device for scene
domoticz3.png (41.95 KiB) Viewed 2690 times
Mysensor node/child devices
Mysensor node/child devices
domoticz2.png (4.25 KiB) Viewed 2690 times
Devicelist
Devicelist
domoticz1.png (9.38 KiB) Viewed 2690 times
Last edited by toreandre on Thursday 07 July 2016 18:30, edited 1 time in total.
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by toreandre »

gizmocuz wrote:you want the domoticz scene to be activated by both child id 3 and 4, regarding the status (on/off), i think you can add multiple activators to a scene/group
if you want to turn off a scene, that is not possible, a scene can only be activated
Otherwise, you can build an Event (blockly) to do this
ANd here is the last attachment
Attachments
domoticz4.png
domoticz4.png (26.7 KiB) Viewed 2690 times
User avatar
gizmocuz
Posts: 2521
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by gizmocuz »

I think you can use 1 scene child_id, and when you send the scene, you give it a number (scene id)

See the MockMySensors example

send(msg_S_SCENE_CONTROLLER_ON.set(sceneVal))

where sceneval is 1,2,3,4,100,...
Quality outlives Quantity!
casio
Posts: 7
Joined: Monday 16 May 2016 12:56
Target OS: Linux
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by casio »

Indeed, as gizmocuz explains, that is much more efficient. I just made a scene controller myself using only a single button to turn a scene on (short click) and off (keep button > 1 sec). Running at 1MHz with BOD disabled to allow the battery voltage to drop down to 1.8V. It consumes only 28uA during deep sleep and is waken-up by an interrupt. So should have a pretty long battery life ;-) However, I think I have a similar request/question as toreandre. The scene controller, which is in fact a plain ON/OFF switch, will not turn on if the state of the "switch" is already on. Hence, the scene will not execute the ON sequence and visa versa.

I've doing some digging and think the reason is as follows. On line 795 and 799 the V_SCENE_ON and V_SCENE_OFF are calling the UpdateSwitch function. This checks if the received value (bOn) is equal to the current value (nvalue). There is already an exception which lead to always updating the value/state. When the vType is V_TRIPPED and the new value is true this below check is skipped. A simple solution would be to also add an additional if condition that checks if the vType != V_SCENE_OFF || vType != V_SCENE_ON... Not sure if this is the neatest solution.

Original code section

Code: Select all

		if (((vType != V_TRIPPED) || (!bOn)) && ((vType != V_SCENE_OFF) || (vType != V_SCENE_ON)))
		{
			//check if we have a change, if not do not update it
			int nvalue = atoi(result[0][1].c_str());
			if ((!bOn) && (nvalue == 0))
				return;
			if ((bOn && (nvalue != 0)))
			{
				//Check Level
				int slevel = atoi(result[0][2].c_str());
				if (slevel == level)
					return;
			}
		}
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by toreandre »

In my case i just changed to S_MOTION and V_TRIPPED for my buttons and it activates my scenes with no problem every time.

Another solution could be to automaticly send the scene_off after the scene_on is sent so the scene is ready to be activated again with the same button.
casio
Posts: 7
Joined: Monday 16 May 2016 12:56
Target OS: Linux
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by casio »

Right, that is indeed a solution. For both solutions are still is not sufficient ;-) as that does not allow the scene to be turned off (if you use a single scene). Since the off state is still not updated (also not for the V_TRIPPED). I will do some experimenting with modifying the UpdateSwitch function. Anyway thanks for the suggestions.
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by toreandre »

casio wrote:Right, that is indeed a solution. For both solutions are still is not sufficient ;-) as that does not allow the scene to be turned off (if you use a single scene). Since the off state is still not updated (also not for the V_TRIPPED). I will do some experimenting with modifying the UpdateSwitch function. Anyway thanks for the suggestions.
But it is not possible to turn a scene off in domoticz? I thought it was only groups that could be turned on and off?
casio
Posts: 7
Joined: Monday 16 May 2016 12:56
Target OS: Linux
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by casio »

Sorry indeed I meant to say group, I was confusing the scene controller with scene's... :-) I'm using a single scene controller as activation device to toggle the group between on and off state as you can see in the attachment.
Screen Shot 2016-07-11 at 22.29.42.png
Screen Shot 2016-07-11 at 22.29.42.png (332.08 KiB) Viewed 2556 times
User avatar
gizmocuz
Posts: 2521
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by gizmocuz »

You can also create an ON and OFF scene (2 scenes) if you like
If you need to control a group, i suggest to send it as a 'light' device from the arduino instead of a scene
Quality outlives Quantity!
casio
Posts: 7
Joined: Monday 16 May 2016 12:56
Target OS: Linux
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by casio »

Hi Gizmocuz, thanks for the tip.
The suggestion I made above should obviously be (vType != V_SCENE_OFF) && (vType != V_SCENE_ON) adding to the if condition in line 1107. This results in all V_SCENE_ON or V_SCENE_OFF to come through no matter what the state of the "switch" is in the domoticz DB. Hence, triggering the group always as desired. So this solves my question. Using the light device will result in vType V_STATUS, right? I think this would result in the same issue as V_SCENE_ON or V_SCENE_OFF.
User avatar
gizmocuz
Posts: 2521
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by gizmocuz »

Thanks, i made the changes, and a new update should be available within the hour...
Hope all works well now
Quality outlives Quantity!
casio
Posts: 7
Joined: Monday 16 May 2016 12:56
Target OS: Linux
Domoticz version:
Contact:

Re: How does the S_SCENE_CONTROLLER work?

Post by casio »

Great thanks for the update. Now i can get rid of the -modified switch ;-)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests