indigo.server.log(f"{appts}")
[('Night Work', 'Nov 29, 2023 at 5:00 PM', 'Nov 30, 2023 at 7:00 AM'), ('OFF', 'Nov 30, 2023 at 12:00 AM', 'Nov 30, 2023 at 11:59 PM'), ('Put keys in Car 10', 'Nov 30, 2023 at 6:45 AM', 'Nov 30, 2023 at 6:46 AM')]
for appt in appts:
if appt[0] == "OFF":
indigo.variable.updateValue(790632292, value='true')
Script [('Night Work', 'Nov 29, 2023 at 5:00 PM', 'Nov 30, 2023 at 7:00 AM'), ('OFF', 'Nov 30, 2023 at 12:00 AM', 'Nov 30, 2023 at 11:59 PM'), ('Put keys in Car 10', 'Nov 30, 2023 at 6:45 AM', 'Nov 30, 2023 at 6:46 AM')]
if "Day Work" in the_string:
indigo.variable.updateValue(1422763041, value='true')
else:
indigo.variable.updateValue(1422763041, value='false')
if "Night Work" in the_string:
indigo.variable.updateValue(15646541, value='true')
else:
indigo.variable.updateValue(15646541, value='false')
if "OFF" in the_string:
indigo.variable.updateValue(790632292, value='true')
else:
indigo.variable.updateValue(790632292, value='false')
if "VAC" in the_string:
indigo.variable.updateValue(41667262, value='true')
else:
indigo.variable.updateValue(41667262, value='false')
jay (support) wrote:I cannot see how to consolidate when every variable update has to call the API.
jay (support) wrote:
One way you might be able to reduce the logging is to attempt to consolidate all those shortcuts into one. I don't know what they do, so that suggestion is just speculation.
10 Aug 2023 at 15:57:58
Action Group Shortcuts
Web Server HTTP API command call received from 92.144.72.119
Web Server API v2 command received, id: '136.867 lx' from '92.144.72.119'
Web Server HTTP API command call received from 92.144.72.119
Web Server API v2 command received, id: '339 lx' from '92.144.72.119'
Web Server HTTP API command call received from 92.144.72.119
Web Server API v2 command received, id: '71' from '92.144.72.119'
Web Server HTTP API command call received from 92.144.72.119
Web Server API v2 command received, id: '21.6°C' from '92.144.72.119'
Trigger Hall Bath Music On Soro
>> /tmp/debug.txt 2>&1
Apple wrote:
The following automations can be run automatically:
Time of Day
Alarm
Sleep
CarPlay
Apple Watch Workout
NFC
App
Airplane Mode
Do Not Disturb
Low Power Mode
Battery Level
Charger
import os
import json
# If key 'AllDay' is set to "True" it will override the Start and End times.
# Double braces are required at the ends of the payload to ensure they're included (and not mistaken for a format specifier).
title = "My Title"
location = "My Location"
notes = "My Notes"
start = "11:00 AM"
end = "1:00 PM"
all_day = "False" # a string
payload = f'{{"Title":"{title}", "Location":"{location}", "Notes":"{notes}", "Start":"{start}", "End":"{end}", "AllDay":"{all_day}"}}'
os.system(f'/usr/bin/shortcuts run "Post Event to Calendar" <<< \'{payload}\'')
payload = {
"Title": "My Title",
"Location": "My Location",
"Notes": "My Notes",
"Start": "11:00 AM",
"End": "1:00 PM",
"Calendar": "Indigo",
"AllDay": True # a boolean
}
payloadj = json.dumps(payload)
result = subprocess.run(["/usr/bin/shortcuts", "run", "Post Event to Calendar"],
input=payloadj.encode("utf-8"),
capture_output=True,
timeout=10
)
print(f"Return Code: {result.returncode}")
print(f"Output: {result.stdout.decode('utf-8')}")
print(f"Errors: {result.stderr.decode('utf-8')}")
import os
val = indigo.variables[123456].value # The value to pass. In this case, a variable value.
os.system(f'/usr/bin/shortcuts run "Post Event to Calendar" <<< \"{val}\"') # Will return 0 on success; 256 on error.
pip3 install --upgrade bimmer_connected
import subprocess
def build_list(my_result):
""" Construct a list of event tuples """
result_str = result.decode('utf-8') # Change bytes object into Unicode string
result_split = [_.split('\n') for _ in result_str.split(' %% ')] # Split payload into a list of lists, first on '%%' then on '\n'
zipped = list(zip(*result_split)) # Zip the lists into a list of tuples (the contents are driven by the shortcut)
return zipped
num_appt = b'3.0'
result = subprocess.run(['/usr/bin/shortcuts', 'run', 'Get Calendar Events'], input=num_appt, check=True, capture_output=True).stdout
appts = build_list(result)
indigo.server.log(f"{appts}")
[('My First Event', 'Mar 20, 2023 at 9:30 AM', 'Mar 20, 2023 at 12:30 PM'), ('My Second Event', 'Mar 21, 2023 at 12:00 AM', 'Mar 21, 2023 at 11:59 PM'), ('My Third Event', 'Mar 24, 2023 at 12:00 AM', 'Mar 27, 2023 at 11:59 PM')]
import os
val = indigo.variables[123456].value
os.system(f'/usr/bin/shortcuts run "Post Event to Calendar" <<< \"{val}\"')
shortcuts run "pass to indigo" <<< '{"message":"indigo.device.toggle", "objectId":"1252158401", "Key Location":"Indigo API Key 2"}'
alarm_clock = indigo.variables[469044268].value # "sveglia"
alarm_cleaned = "0" + alarm_clock.split()[0]
indigo.variable.updateValue(469044268, value=alarm_cleaned)