Script that compare temperature reading from two sensors

Posted on
Sat Oct 05, 2019 1:08 am
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Script that compare temperature reading from two sensors

Have installed a series of Aeotec "Multisensor 6" throughout my house (internally & externally), I also have a series of high windows fitted with Fakro window winders.
I'm trying to create a trigger that will automatically open all the high windows when external forecasted temperature (using Cynical Weather) is above 26°C, and the current temperature from the external Multisensor 6 is below the temperature from one or multiple internal Multisensor 6's.

Does anyone know how I have compare the temperature reading between the two Multisensor 6?

Posted on
Sat Oct 05, 2019 6:11 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script that compare temperature reading from two sensors

Eagleye wrote:
Have installed a series of Aeotec "Multisensor 6" throughout my house (internally & externally), I also have a series of high windows fitted with Fakro window winders.
I'm trying to create a trigger that will automatically open all the high windows when external forecasted temperature (using Cynical Weather) is above 26°C, and the current temperature from the external Multisensor 6 is below the temperature from one or multiple internal Multisensor 6's.

Does anyone know how I have compare the temperature reading between the two Multisensor 6?

Are you on Indigo 7.4? If so, create a trigger with the following condition.

[If Python script returns True:]
Code: Select all
outside_temp  = indigo.devices[12345678].states['sensorValue']
inside_temp   = indigo.devices[12345678].states['sensorValue']

return inside_temp > outside_temp

Should work. Obviously, you'll need to replace the device ID numbers with your own (be sure to use the ID for the temperature device and not the motion device, etc.).

If you're not on Indigo 7.4, you can still do it--but the process is slightly different.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Oct 05, 2019 7:05 am
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Thanks Dave, I really appreciate your help on this.

Given that the Multisensor picks up six different variables, including temperature. How does your script know to select temperature?

Can you please point me to the Device ID # is should be using to make this work, from the info below.

My external sensor shows the following
infoIndigo Z-Wave Version: 7.4.0
Node ID: 21
Model: Multi Sensor 6 (ZW100)
Model ID: 02020064
Manufacturer: Aeon Labs
Manufacturer ID: 0086
Protocol Version: 4.05
Application Version: 1.08
Model Definition Version: 4
Library Type: 3
Class Name: Multilevel Sensor (routing)
Class Hierarchy: 04 : 21 : 01
Command Class Base: 31
Command Versions: 20v1 80v1 84v2 85v1 86v1 30v1 70v1 31v5 72v1 73v1 71v1 59v1 7Av1 5Av1 5Ev1
Encryption Status: Not Supported
Multi-Endpoint Types: - none -
Multi-Endpoint Classes: - none -
Multi-Instance Counts: - none -
Features: routing, battery, beaming, waking
Neighbors: 2, 3, 4, 7, 24, 25, 26, 27, 28, 29, 50, 67, 70, 71, 74
Associations: 1:[1]
Config Values: 64:1 2:0 3:240 4:5 5:1 101:240 102:0 103:0 40:0 111:900 112:1800 113:1800 252:0


and the internal sensor shows the following.
Indigo Z-Wave Version: 7.4.0
Node ID: 6
Model: Multi Sensor 6 (ZW100)
Model ID: 02020064
Manufacturer: Aeon Labs
Manufacturer ID: 0086
Protocol Version: 4.05
Application Version: 1.08
Model Definition Version: 4
Library Type: 3
Class Name: Multilevel Sensor (routing)
Class Hierarchy: 04 : 21 : 01
Command Class Base: 31
Command Versions: 20v1 80v1 84v2 85v1 86v1 30v1 70v1 31v5 72v1 73v1 71v1 59v1 7Av1 5Av1 5Ev1
Encryption Status: Not Supported
Multi-Endpoint Types: - none -
Multi-Endpoint Classes: - none -
Multi-Instance Counts: - none -
Features: routing, battery, beaming, waking
Neighbors: 2, 3, 7, 9, 11, 13, 14, 15, 17, 19, 24, 25, 26, 27, 28, 29, 30, 36, 39, 40, 44, 46, 50, 65, 66, 67, 71, 72, 74
Associations: 1:[1]
Config Values: 64:1 2:0 3:240 4:5 5:1 102:0 103:0 40:0 111:1800 112:1800 113:1800 252:0 101:240

Posted on
Sat Oct 05, 2019 7:12 am
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

The Multisensor 6 picks up - Temperature, Humidity, Luminance, Ultraviolet light, motion & tampering. I just want to focus on temperature.

Posted on
Sat Oct 05, 2019 7:17 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Script that compare temperature reading from two sensors

When you sync the Multisensor 6 to Indigo, Indigo creates six linked devices (one for each type). You need to specify the device Id of the temperature device. :)

Posted on
Sat Oct 05, 2019 7:42 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script that compare temperature reading from two sensors

Right. Find the temperature device in the Indigo device list, right click on it and select "Copy ID". Paste that in place of the dummy value in the script above.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Oct 07, 2019 4:51 am
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Thanks guys, I hide the Device ID # in the device list, I think I have managed to work it out.

Thank you for your help.

Posted on
Mon Oct 07, 2019 5:39 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script that compare temperature reading from two sensors

Glad you were able to do what you needed.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Oct 23, 2019 3:25 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Further to this scrip inquiry, I would like to add a condition that needs the internal temperature to be greater than 19°C

With your assistance, I have created the following, but I'm not sure how to add a greater than clause, see blue writing below..

outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

return inside_temp > outside_temp
indigo.devices[1450104654].states[19]

Any help would greatly be appreciated.

Posted on
Wed Oct 23, 2019 3:46 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script that compare temperature reading from two sensors

I'm not entirely clear on what you're trying to accomplish, so I'll take a guess.

Code: Select all
outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

if inside_temp > 19:
    return inside_temp > outside_temp

But I'm not certain that's what you're after. If you want the condition to be 19 or greater, change the ">" to ">=".

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Oct 23, 2019 4:02 pm
FlyingDiver offline
User avatar
Posts: 7221
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

You need an else clause and another return statement. Probably just "return False". That may be the default in Python, but much better to do it explicitly so you don't wonder a year from now.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Oct 23, 2019 4:18 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script that compare temperature reading from two sensors

FlyingDiver wrote:
You need an else clause and another return statement. Probably just "return False". That may be the default in Python, but much better to do it explicitly so you don't wonder a year from now.


+1 - for Python condition scripts, you should always return either True or False.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 23, 2019 5:38 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Script that compare temperature reading from two sensors

Good call. The first script would return True or False by definition, but my revision wouldn't without the else.

Code: Select all
outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

if inside_temp > 19:
    return inside_temp > outside_temp
else:
    # uncomment one or the other.
    # return True
    # return False

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Oct 24, 2019 7:35 pm
Eagleye offline
Posts: 83
Joined: Jan 14, 2019

Re: Script that compare temperature reading from two sensors

Just to clarify, I want to create a condition that checks the internal temperature via a multi-sensor to ensure it is greater than 19°C, before comparing the internal & external temperature. If the external temperature is less than the internal temperature, open all motorised windows.

The trigger here to to check the forecasted temperature for the following day is going to be greater than 26°C

I cut & pasted you script below into into my trigger event, and I got a message "embedded script: expected an indented block". Can you please advise what this mean?

Posted on
Thu Oct 24, 2019 7:46 pm
FlyingDiver offline
User avatar
Posts: 7221
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Script that compare temperature reading from two sensors

Eagleye wrote:
I cut & pasted you script below into into my trigger event, and I got a message "embedded script: expected an indented block". Can you please advise what this mean?


It means you have the indentation in the script wrong. Python is very dependent on correct indentation. On the other hand, the sample script posted above needs to have ONE of the last two lines uncommented to work. If they're both commented out, then you have no executable line after the else statement, which will give the same error.

I think you need:
Code: Select all
outside_temp = indigo.devices[209400252].states['sensorValue']
inside_temp = indigo.devices[1450104654].states['sensorValue']

if inside_temp > 19:
    return inside_temp > outside_temp
else:
    return False

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Who is online

Users browsing this forum: brettlid and 7 guests