Method for storing variables

Hi All,

I’m looking for a HA equivalent in St.

I want a way to store a variable that can be read by any device.

Im using 1no lux sensor to control multiple lights.

Issue bring that if the light is on in the room the lux meter is in, the rest of the rooms read as if it’s not dark enough to operate.

So what I’d like to do is to periodically pass the lux value into a variable that then can be read by any device.

In HA this would be done with a ‘helper’.

Im not sure if the solution is to create a virtual device that gets assigned the lux level, say every 5 muns or a smart app that holds variables.

Any ideas?

Storing values to variables is not possible

I have used to two virtual switches illuminance level enough dark and enough light

And then Rules API rules comparisons

					{
						"greaterThan": {
						"left": {
						"device": {
						  "devices": [
							"device id"
							],
							"component": "main",
							"capability": "illuminanceMeasurement",
							"attribute": "illuminance",
							}			
						},
						"right": {						
							"integer": 100
						}
						}
					}
				],

and

					{
						"lessThan": {
						"left": {
						"device": {
						  "devices": [
							"device id"
							],
							"component": "main",
							"capability": "illuminanceMeasurement",
							"attribute": "illuminance",
							}			
						},
						"right": {						
							"integer": 100
						}
						}
					}
				],

then I have used virtual switches illuminance level enough dark and enough light in automations

The virtual switches illuminance level enough dark and enough light are only updated if lights are off.

Of course you can do the comparisons using automations

You can also use number fields to store variables
[(New Release) Edge Driver Virtual Appliances Mc (virtual Switch Mirror, Virtual Calendar and virtual Switch Board) - Devices & Integrations / Community Created Device Types - SmartThings Community](https://community.smartthings.com/t/new-release-edge-driver-virtual-appliances-mc-virtual-switch-mirror-virtual-calendar-and-virtual-swit ( Lux ) ch-board/243627/26)

Using Rules API you can store Illuminance ( Lux ) value to number field

Example command

		{
			"command": {
				"devices": [
					"Device_Id_Number_Field"
				],
				"commands": [
					{
						"component": "main",
						"capability": "legendabsolute60149.numberFieldOne",
						"command": "setNumberFieldOne",
						"arguments": [
							{
								"device": {
									"devices": [
										"Device_Id_Illuminance_Measurement"
									],
									"component": "main",
									"capability": "illuminanceMeasurement",
									"attribute": "illuminance"
								}
							}
						]
					}
				]
			}
		}

then you can use number field in automations

1 Like

It is possible in an Edge driver, but I suspect this question is limited to the Rules API. Inside an Edge driver you can use device:set_field(key, value)

3 Likes