import re
# Select the Weather String to Parse based on time of day
# Get the value of the "MorningDaytimeEveningNightime" variable
mde_value = indigo.variables["MorningDaytimeEveningNightime"].value.lower()
# Check the value and update "WeatherStringToParse" accordingly
if mde_value in ["eveningtime"]:
weather_string = indigo.variables["WeatherNOAAForecastStringTonight"].value
weather_string_to_parse = "Tonight: " + weather_string
indigo.variable.updateValue("WeatherStringToParse", value=weather_string_to_parse)
elif mde_value in ["morning", "daytime"]:
weather_string = indigo.variables["WeatherNOAAForecastStringToday"].value
weather_string_to_parse = "Today: " + weather_string
indigo.variable.updateValue("WeatherStringToParse", value=weather_string_to_parse)
elif mde_value in ["nighttime"]:
weather_string = indigo.variables["WeatherNOAAForecastStringTomorrow"].value
weather_string_to_parse = "Tomorrow: " + weather_string
indigo.variable.updateValue("WeatherStringToParse", value=weather_string_to_parse)
# now parse the selected string
# The name of the Indigo variable to monitor
WeatherStringToParse = indigo.variables["WeatherStringToParse"].value
# The length of each phrase
phrase_length = int(indigo.variables["WeatherStringPhraseToDisplayLen"].value)
# Split the current value into words with original capitalization and punctuation
words = re.findall(r'\w+|\s*\W+', WeatherStringToParse)
# Combine words into phrases with the specified length
parsed_phrases = []
phrase = ""
for word in words:
if len(phrase) + len(word) <= phrase_length:
phrase += word
else:
parsed_phrases.append(phrase.strip())
phrase = word
if phrase.strip():
parsed_phrases.append(phrase.strip())
# Save the parsed phrases in the WeatherPhraseList variable
indigo.variable.updateValue("WeatherPhraseList", value=str(parsed_phrases))
# Update the number of phrases
indigo.variable.updateValue("WeatherStringNumberOfPhrases", value=str(len(parsed_phrases)))
# Transfer one of the phrases to another Indigo variable
if parsed_phrases:
# Get the index of the current phrase
current_index_str = indigo.variables["WeatherStringPhraseCount"].value
if current_index_str == "":
current_index_str = "0"
current_index = int(current_index_str)
# Get the number of phrases
number_of_phrases_str = indigo.variables["WeatherStringNumberOfPhrases"].value
if number_of_phrases_str == "":
number_of_phrases_str = "0"
number_of_phrases = int(number_of_phrases_str)
# Check if the current index is within the range of parsed_phrases
if 0 <= current_index < number_of_phrases:
# Set the value of the display variable to the current phrase
indigo.variable.updateValue("WeatherStringToDisplay", value=str(parsed_phrases[current_index]))
# Update the index of the current phrase
current_index = (current_index + 1) % number_of_phrases
indigo.variable.updateValue("WeatherStringPhraseCount", value=str(current_index))
else:
indigo.server.log("Error: Current index is out of range")
try:
import indigo
except ImportError:
pass
indigo-host -e 'return indigo.actionGroup.execute(12345678)'
curl -X POST -H "Authorization: Bearer abc123-abc123-abc123" -d '{"message":"indigo.actionGroup.execute","objectId":238475738}' https://YOUR-REFLECTOR.indigodomo.net/v2/api/command
curl -X POST -H "Authorization: Bearer abc123-abc123-abc123" -d '{"message":"indigo.actionGroup.execute","objectId":238475738}' http://127.0.0.1:8176/v2/api/command
dev = indigo.devices[1666063006] # amb light sensor (state)
ambLt = int(state)
varA = ambLt
varA = int(state)
compare new state value with lastAmbLtLevel
if(it’s the same or near enough):
Accept it is true
insert new state to trueAmbLtLevel
else(it’s noisy)
Don’t do anything
#Regardless, store value for next comparison:
insert new state to variable lastAmbLtLevel
Turn lights on/off accordingly
import time
varA = indigo.variables[714999465].getValue(int) # ambLt_0
varB = indigo.variables[911378874].getValue(int) # ambLt_1
varD = indigo.variables[602276231].getValue(bool) # ambLtValid
indigo.trigger.enable(913722846, False) #disable trigger while checking
dev = indigo.devices[1666063006] # amb light sensor (state)
ambLt = int(dev.states["state"])
varA = ambLt # initial value
time.sleep(5) #delay to allow possibly aberrant reading to be ignored
ambLt = int(dev.states["state"])
varB = ambLt # second value
if varA == varB:
indigo.variable.updateValue(602276231, "True")
else:
indigo.variable.updateValue(602276231, "False")
indigo.trigger.enable(913722846, True) #enable enable trigger
if varA == varB:
try:
import indigo
except:
pass
if b'Error' in line:
import os
from datetime import date
baseDir = indigo.server.getInstallFolderPath()
tmpFileName = os.path.join(baseDir, 'Logs/tmp.txt')
fileDate = str(date.today())
eventFileName = os.path.join(baseDir, 'Logs/' + fileDate + ' Events.txt')
theBody = ''
with open(tmpFileName, 'a') as tmpFile:
with open( eventFileName, 'r' ) as log:
for line in log:
if 'Error' in line:
tmpFile.write(line.encode('UTF-8'))
theBody += line
# theBody is the body of an email which is sent next
print theBody
indigo.variable.updateValue(1155409051, value=theBody)
theSubject = "All Indigo Event Log Errors"
indigo.variable.updateValue(1695073597, value=theSubject)
import os
from datetime import date
baseDir = indigo.server.getInstallFolderPath()
tmpFileName = os.path.join(baseDir, 'Logs/tmp.txt')
fileDate = str(date.today())
eventFileName = os.path.join(baseDir, 'Logs/' + fileDate + ' Events.txt')
theBody = ''
with open(tmpFileName, 'a') as tmpFile:
with open( eventFileName, 'r' ) as log:
for line in log:
if 'Error' in line:
tmpFile.write(line)
theBody += line
# theBody is the body of an email which is sent next
print theBody
indigo.variable.updateValue(1155409051, value=theBody)
theSubject = "All Indigo Event Log Errors"
indigo.variable.updateValue(1695073597, value=theSubject)
from datetime import datetime
today = datetime.date.today()
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
indigo.variable.updateValue(748482965, value="start;1234;" + today + "09:00;" + today + "17:00") #where the number is the VarID for id_X
import os, shutil, datetime, time, subprocess
from time import strftime
from datetime import datetime, timedelta
import requests
from requests.auth import HTTPDigestAuth
from ast import literal_eval
#execute the data Downloader saving data to file rather than PIPE that might overflow buffer
p=subprocess.Popen('java -jar ~/documents/emporiadownloader/emporia-downloader.1.2.jar --username EMAIL --password PASSWORD --raw --scale m --disable-influx=true --history 1m --sleep 0 --quiet --logfile ~/documents/emporiadownloader/emporialog.txt >~/documents/emporiadownloader/emporiadata.json', shell=True)
p.wait()
# Read data from file
with open('~/documents/emporiadownloader/emporiadata.json', 'r') as infile:
lines = infile.readlines()
# Convert the string representation of the data to individual dicts and get rid of any "null"s.
new_lines = [literal_eval(line.replace('null,null', '-1.0')) for line in lines]
# Combine into a single dict (optional)
line_dict = {}
x = 1
#Copy the data to the appropriate variables
for line in new_lines:
line_dict[x] = line
#if no data for channel keep prior value
if line_dict[x]["usageList"][0] < 0 :
continue
#Convert total KWH for prior minute into average watts as a string
Power = str(round(line_dict[x]["usageList"][0]*60000))
#Load Power into the appropriate variable
if line_dict[x]["channel"] == "1" :
#AC1
indigo.variable.updateValue(1205466672, value = Power)
if line_dict[x]["channel"] == "2" :
#Fan1
indigo.variable.updateValue(625300994, value = Power)
if line_dict[x]["channel"] == "3" :
#fan 2
indigo.variable.updateValue(204858724, value = Power)
if line_dict[x]["channel"] == "4" :
#AC2
indigo.variable.updateValue(366529428, value = Power)
if line_dict[x]["channel"] == "5" :
#Stove
indigo.variable.updateValue(1510404434, value = Power)
if line_dict[x]["channel"] == "6" :
#Hot Water Heater
indigo.variable.updateValue(1585403834, value = Power)
if line_dict[x]["channel"] == "7" :
#Dryer
indigo.variable.updateValue(1755332382, value = Power)
if line_dict[x]["channel"] == "8" :
#Septic
indigo.variable.updateValue(1680593288, value = Power)
if line_dict[x]["channel"] == "9" :
#Living Room
indigo.variable.updateValue(1097926420, value = Power)
if line_dict[x]["channel"] == "10" :
#Master 1
indigo.variable.updateValue(1173427536, value = Power)
if line_dict[x]["channel"] == "11" :
#Master 2
indigo.variable.updateValue(1811108695, value = Power)
if line_dict[x]["channel"] == "12" :
#Washer
indigo.variable.updateValue(1176479276, value = Power)
if line_dict[x]["channel"] == "13" :
#Server
indigo.variable.updateValue(1096942489, value = Power)
if line_dict[x]["channel"] == "14" :
#Server
indigo.variable.updateValue(1911961433, value = Power)
if line_dict[x]["channel"] == "15" :
#Jeff
indigo.variable.updateValue(1670122551, value = Power)
if line_dict[x]["channel"] == "16" :
#Server
indigo.variable.updateValue(1252297191, value = Power)
x += 1
#! /usr/bin/python2.7
import requests
url = 'https://MYREFLECTOR/devices/Office%20Lamp?toggle=1&_method=put'
requests.get(url, auth=requests.auth.HTTPDigestAuth('username', 'password'))
# IndigoCheckSunrise.py by B. Barretto, 30 Apr 2021
#
# Script to calculate time diff from sunrise so that we can control the lights in the morning
# What we want is to turn on lights only if the time we are running this (schedule time)
# is after (factor) minutes from sunrise. Basically, if there is enough light outside
# don't bother turning on the lights in the morning, like fifteen minutes before sunrise.
#
# If factor is -15 minutes and sunrise is at 6am, calculated sunrise is 5:45am. If the schedule time is 6:15am,
# then schedule time is later, so we do not turn on the lights because by this time there should
# be enough light in the sky.
#
# If sunrise is at 7am, then calculated sunrise is 6:45am. This is after schedule time, so we turn on the lights
# because it should still be too dark outside.
import datetime
# time in minutes relative to sunrise
factor = -15
# calculate adjusted sunrise with factor above
timeItIsBrightEnough = indigo.server.calculateSunrise(indigo.server.getTime().date()) + datetime.timedelta(minutes=factor)
# we're going to use this multiple times, so calculate once and store
rightFrigginNow = datetime.datetime.now()
# take difference between calculated sunrise time and now, result is data type datetime.timedelta
# A negative value calculated means that it is now before the time it is "bright enough"
timeDelta = rightFrigginNow - timeItIsBrightEnough
# if timeDelta is negative (script execute time is before adjusted sunrise), return boolean True
isBeforeAdjustedSunrise = timeDelta < datetime.timedelta(minutes=0)
# build message
if isBeforeAdjustedSunrise:
logMsg = "Turn on the lights"
else:
logMsg = "Do NOT turn on the lights"
indigo.server.log("Now: " + rightFrigginNow.strftime("%H:%M:%S") + ", Target time: " + str(timeItIsBrightEnough) +
", calculated diff: " + str(timeDelta) + ", Before calculated sunrise? " + str(isBeforeAdjustedSunrise) + ", " + logMsg)
return isBeforeAdjustedSunrise
indigo.device.turnOn[985370218] # "Siren 1- button 1 chimes"
indigo.device.turnOn[985370218] # "Siren 1- button 1 chimes"
import requests
grant_type = 'password'
client_id = '<YourHusqvarnaDeveloperAppID>'
username = '<YourHusqvarnaAppUserName>'
password = '<YourHusqvarnaAppPassword>'
post_url = 'https://api.authentication.husqvarnagroup.dev/v1/oauth2/token'
payload = {
'grant_type': grant_type,
'client_id': client_id,
'username': username,
'password': password,
}
r = requests.post(post_url, data = payload)
indigo.server.log(str(r.text))
https://api.amc.husqvarna.dev/v1/mowers
-X GET \
-H "accept: application/vnd.api+json" \
-H "X-Api-Key: < YourHusqvarnaDeveloperAppID>" \
-H "Authorization: Bearer <YourHusqvarnaTokenFromStep1>" \
-H "Authorization-Provider: husqvarna"
url: https://api.amc.husqvarna.dev/v1/mowers/<YourMowerFromMowerList>
-X GET \
-H "accept: application/vnd.api+json" \
-H "X-Api-Key: < YourHusqvarnaDeveloperAppID>" \
-H "Authorization: Bearer <YourHusqvarnaTokenFrom Step1>" \
-H "Authorization-Provider: husqvarna"
# Park Until Further Notice
import requests
mower = (indigo.variables['husqvarnaMower'].value)
authorization = (indigo.variables['husqvarnaAuthorization'].value)
apikey = (indigo.variables['husqvarnaAPIKey'].value)
post_url = 'https://api.amc.husqvarna.dev/v1/mowers/' + mower + '/actions'
head = {
'accept': '*/*',
'X-Api-Key': apikey,
'Authorization': authorization,
'Authorization-Provider': 'husqvarna',
'Content-Type': 'application/vnd.api+json',
}
payload = '{"data":{"type":"ParkUntilFurtherNotice"}}'
r = requests.post(post_url, headers = head, data = payload)
if str(r.status_code) == '202':
indigo.server.log('Husqvarna Parked Until Further Notice')
indigo.variable.updateValue('husqvarnaParked', value=str('true'))
# Resume Schedule
import requests
mower = (indigo.variables['husqvarnaMower'].value)
authorization = (indigo.variables['husqvarnaAuthorization'].value)
apikey = (indigo.variables['husqvarnaAPIKey'].value)
post_url = 'https://api.amc.husqvarna.dev/v1/mowers/' + mower + '/actions'
head = {
'accept': '*/*',
'X-Api-Key': apikey,
'Authorization': authorization,
'Authorization-Provider': 'husqvarna',
'Content-Type': 'application/vnd.api+json',
}
payload = '{"data":{"type":"ResumeSchedule"}}'
r = requests.post(post_url, headers = head, data = payload)
if str(r.status_code) == '202':
indigo.server.log('Husqvarna Resume Schedule')
indigo.variable.updateValue('husqvarnaParked', value=str('false'))
husqvarnaError = str(indigo.variables[1384099050].value) # "husqvarnaErrorCode"
dict = {
'0': 'Unexpected error',
'1': 'Outside working area',
'2': 'No loop signal',
'3': 'Wrong loop signal',
'4': 'Loop sensor problem, front',
'5': 'Loop sensor problem, rear',
'6': 'Loop sensor problem, left',
'7': 'Loop sensor problem, right',
'8': 'Wrong PIN code',
'9': 'Trapped',
'10': 'Upside down',
'11': 'Low battery',
'12': 'Empty battery',
'13': 'No drive',
'14': 'Mower lifted',
'15': 'Lifted',
'16': 'Stuck in charging station',
'17': 'Charging station blocked',
'18': 'Collision sensor problem, rear',
'19': 'Collision sensor problem, front',
'20': 'Wheel motor blocked, right',
'21': 'Wheel motor blocked, left',
'22': 'Wheel drive problem, right',
'23': 'Wheel drive problem, left',
'24': 'Cutting system blocked',
'25': 'Cutting system blocked',
'26': 'Invalid sub-device combination',
'27': 'Settings restored',
'28': 'Memory circuit problem',
'29': 'Slope too steep',
'30': 'Charging system problem',
'31': 'STOP button problem',
'32': 'Tilt sensor problem',
'33': 'Mower tilted',
'34': 'Cutting stopped - slope too steep',
'35': 'Wheel motor overloaded, right',
'36': 'Wheel motor overloaded, left',
'37': 'Charging current too high',
'38': 'Electronic problem',
'39': 'Cutting motor problem',
'40': 'Limited cutting height range',
'41': 'Unexpected cutting height adj',
'42': 'Limited cutting height range',
'43': 'Cutting height problem, drive',
'44': 'Cutting height problem, curr',
'45': 'Cutting height problem, dir',
'46': 'Cutting height blocked',
'47': 'Cutting height problem',
'48': 'No response from charger',
'49': 'Ultrasonic problem',
'50': 'Guide 1 not found',
'51': 'Guide 2 not found',
'52': 'Guide 3 not found',
'53': 'GPS navigation problem',
'54': 'Weak GPS signal',
'55': 'Difficult finding home',
'56': 'Guide calibration accomplished',
'57': 'Guide calibration failed',
'58': 'Temporary battery problem',
'59': 'Temporary battery problem',
'60': 'Temporary battery problem',
'61': 'Temporary battery problem',
'62': 'Temporary battery problem',
'63': 'Temporary battery problem',
'64': 'Temporary battery problem',
'65': 'Temporary battery problem',
'66': 'Battery problem',
'67': 'Battery problem',
'68': 'Temporary battery problem',
'69': 'Alarm! Mower switched off',
'70': 'Alarm! Mower stopped',
'71': 'Alarm! Mower lifted',
'72': 'Alarm! Mower tilted',
'73': 'Alarm! Mower in motion',
'74': 'Alarm! Outside geofence',
'75': 'Connection changed',
'76': 'Connection NOT changed',
'77': 'Com board not available',
'78': 'Slipped - Mower has Slipped.Situation not solved with moving pattern',
'79': 'Invalid battery combination - Invalid combination of different battery types.',
'80': 'Cutting system imbalance Warning',
'81': 'Safety function faulty',
'82': 'Wheel motor blocked, rear right',
'83': 'Wheel motor blocked, rear left',
'84': 'Wheel drive problem, rear right',
'85': 'Wheel drive problem, rear left',
'86': 'Wheel motor overloaded, rear right',
'87': 'Wheel motor overloaded, rear left',
'88': 'Angular sensor problem',
'89': 'Invalid system configuration',
'90': 'No power in charging station',
}
dict[husqvarnaError]
indigo.server.log(str(dict[husqvarnaError]))
indigo.variable.updateValue('husqvarnaErrorCodeText', value=str(dict[husqvarnaError]))
# Set parameters for hidden motion sensors, including heartbeat interval and LED mode.
# This script is useful to set up Insteon Hidden Motion Sensor (2845-222).
#
# author: D. Duff user dduff617 on forums.indigodomo.com (duff@alum.mit.edu)
#
# Why?
# a) Indigo doesn't currently provide any UI for accessing these settings.
# b) Prolong battery life.
# c) Cut down unnecessary Insteon traffic
#
# What exactly does this do?
# Sets the heartbeat interval. Value can be set from 5 mins to "about a day". I use heartbeat
# for battery monitoring and as such, for me there's really no point in setting it to anything
# other than max value to save batteries and reduce network traffic.
# Turns off LED. Again this is done primarily to save battery - nothing but a waste of battery
# having an LED shine when buried inside a hole in my doorframe.
#
# BEFORE RUNNING THIS SCRIPT
# First, set this to the name of the device you want to configure.
d = indigo.devices["FOY-CLOS Door Open"]
# Next, Put device in linking mode by holding the set button (if device is out of the wall)
# If device is installed in the wall, you can put it in linking mode, by executing the following steps:
# 1. push the plunger
# 2. release
# 3. push the plunger
# 4. release
# 5. push the plunger and hold it until device beeps.
# 6. release the plunger.
# You have to do steps 1-5 in very quick succession. The beep is not very loud, so you have to listen for it.
# The device stays in linking mode for about a minute.
# set heartbeat interval extended command to door sensor, returns a standard ack.
# note that while heartbeat interval can be set, the results must be observed indirectly
# (as the time delta between successive heartbeats). Value can not be read directly from
# the device, which is kind of annoying.
def setHeartbeatInterval (device, value=0) :
setHeartbeatIntervalCmd = [
0x2E,
0x00,
0x00, # unused
0x02, # set hearbeat interval command
value # heartbeat interval value. 0x01->5min, 0x02->10min, 0x03->15min etc. special 0->"about 24 hrs" (emperically, turns out to be roughly in the range of 19:45 to 21:40)
]
indigo.server.log("Attempting to set heartbeat for device {} to {}".format(device.name, value))
# setting calcCrc=True here will cause it to fail - why? i don't know.
reply = indigo.insteon.sendRawExtended(device.address, setHeartbeatIntervalCmd, suppressLogging=True)
if reply.cmdSuccess :
# indigo.server.log("reply success: {:d}, ack value: {:#x}".format(reply.cmdSuccess, reply.ackValue))
indigo.server.log("Heartbeat interval for device {} was successfully set to {} or {}".format(device.name, value, describeSensorHeartbeat(value)))
return True
else:
indigo.server.log("Extended command failed. Device may be offline?", isError=True)
return false
def describeSensorHeartbeat(value) :
if value==0 :
return "about 24 hours"
else:
return "{} minutes".format(5*value)
# read operating flags is a standard (not extended) command.
# should return result in a standard ack (?) with the interesting results packed into a single reply byte.
# note: this does not return the heartbeat interval and afaik, there is no way to do this.
def readOperatingFlags (device):
# indigo.server.log("Attempting to read operating flags 0 for device {}".format(device.name))
reply = indigo.insteon.sendRaw(device.address, [0x1f, 0x00], waitUntilAck=True, suppressLogging=True)
if reply.cmdSuccess:
# indigo.server.log("reply success: %d, ack value: %02X" % (reply.cmdSuccess, reply.ackValue))
# indigo.server.log("ReplyBytes: {}".format(reply.replyBytes))
indigo.server.log("Operating Flags for device {}".format(device.name))
describeOperatingFlags(reply.ackValue)
else:
indigo.server.log("Command failed. Device may be offline?")
def describeOperatingFlags (reply) :
# indigo.server.log("calling descibeOperatingFlags with reply {}".format(reply))
# info from "Developer Notes" for 2845-222 dated October 2013.
# bit 0 = Do Cleanup Report
# bit 1 = 2 Groups
# bit 2 = Repeat Open
# bit 3 = Repeat Closed
# bit 4 = Link to FF Group
# bit 5 = LED Disable
# bit 6 = N/A
# bit 7 = Programming Lock
indigo.server.log("Do Cleanup Report: {}".format((reply & 1<< 0) > 0))
indigo.server.log("2 Groups: {}".format((reply & 1<<1) > 0))
indigo.server.log("Repeat Open: {}".format((reply & 1<<2 ) > 0))
indigo.server.log("Repeat Closed: {}".format((reply & 1>>3) > 0))
indigo.server.log("Link to FF Group: {}".format((reply & 1<<4) > 0))
indigo.server.log("LED Disable: {}".format((reply & 1<<5) > 0))
# indigo.server.log("Unused flag: {}".format((reply & 1<<6) > 0))
indigo.server.log("Programming Lock: {}".format((reply & 1<<7) > 0))
# set LED Mode. mode=True means LED is ON. mode=False means LED is OFF, aka disabled.
def setLEDMode (device, mode=False):
indigo.server.log("Attempting to set LED Mode for device {} to {}".format(device.name, mode))
cmdBytes = [0x20, 0x03 if mode else 0x02]
reply = indigo.insteon.sendRawExtended(device.address, cmdBytes, suppressLogging=True)
if reply.cmdSuccess:
#indigo.server.log("Reply success: {:d}, Ack value: {:02X}, ReplyBytes: {}".format(reply.cmdSuccess, reply.ackValue, reply.replyBytes))
indigo.server.log("LED mode for device {} was successfully set to {}".format(device.name, mode))
return True
else:
indigo.server.log("Command failed. Device may be offline?", isError=True)
return False
# simple ping to test that a device is awake.
def awakeCheck (device):
result = indigo.device.ping(d, suppressLogging=True)
if result["Success"]:
indigo.server.log("Device is awake and listening. %.2f seconds ping for %s" % (result["TimeDelta"]/1000.0, device.name))
return True
else:
indigo.server.log("ping failed for %s" % (d.name), isError=True)
return False
#
# here's where the action happens:
if (not awakeCheck(d)):
indigo.server.log("Device is not awake or not in range. Quitting.", isError=True)
quit()
# set heartbeat interval (to save batteries)
if (not setHeartbeatInterval(d)):
indigo.server.log("Set heartbeat interval failed. Quitting.", isError=True)
quit()
# turn off LED
if not setLEDMode(d):
indigo.server.log("Set LED Mode failed. Quitting.")
quit()
# dump the current operating flags to logs so we can confirm LED status and other settings.
readOperatingFlags(d)
global = (salon or guille or libre)
salon = bool(indigo.variables[1557076559].value) # insert ID of Termost_salon_CFH variable
guille = bool(indigo.variables[1471718955].value) # insert ID of Termost_Guille_CFH variable
libre = bool(indigo.variables[91898717].value) # insert ID of Termost_libre_CFH variable
global = (salon OR guille OR libre)
indigo.variable.updateValue(1505457529, str(global)) #insert ID of CFH_global variable
indigo.variable.updateValue(525681493, value=str(mowerStatus))#Change number to yours variable ID
indigo.variable.updateValue(145221338, value=str(batteryPercent))#Change number to yours variable ID
import requests
import json
activity_name = indigo.variables[240209652].value # "SimConActivity"
indigo.server.log('attempting to run ' + activity_name + ' on the simple control hub')
# http request, this makes the assumption that Simple Control Hub is on the same server as indigo
# This request will grab the list of all the activities
r = requests.get('http://127.0.0.1:47147/api/v1/activities')
if r.status_code == 200:
# Request was successful, grab the data from the response
data = json.loads(r.text)
# Search through the list of activities looking for the one we want to run, then get the uuid of the activity
uuid = ''
for d in data['data']:
if d['name'] == activity_name:
uuid = d['uuid']
# We found the activity becase the uuid is not blank
if uuid != '':
indigo.server.log('found uuid ' + uuid + ' for ' + activity_name)
# Post to run the activity, assumes simplecontrol hub is on the same server
r = requests.post('http://127.0.0.1:47147/api/v1/runactivity', json = {'activity_uuid':uuid})
# The post was successful
if r.status_code != 200:
indigo.server.log('post request failed, error code ' + str(r.status_code))
else:
indigo.server.log('Activity ' + activity_name + ' requested to start')
else:
indigo.server.log('Could not find activity ' + activity_name)
else:
indigo.server.log('get request failed, error code: ' + str(r.status_code))