{
"_type": "cmd",
"action": "setWaypoints",
"waypoints": {
"_type": "waypoints",
"waypoints": [
{
"_type": "waypoint",
"tst": %%d:1183167460:tst%%,
"rid": "my-lock-id-001",
"desc": "GEOLOCK_Bill|1|2",
"rad": 50,
"lat": %%d:1183167460:lat%%,
"lon": %%d:1183167460:lon%%
}
]
}
}
{
"_type": "cmd",
"action": "setWaypoints",
"waypoints": {
"_type": "waypoints",
"waypoints": [
{
"_type": "waypoint",
"tst": 1708703484,
"rid": "my-lock-id-001",
"desc": "GEOLOCK_Bill|1|2",
"rad": 50,
"lat": 100.0,
"lon": 500.0
}
]
}
}
### Get the current date and time and put in a varible to add to the message later ###
import datetime
now = indigo.server.getTime()
dtg = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
### Get the event type and "tid". Match "tid" with a friendly name.
Event = indigo.devices[609931909].states["event"] # State "event" of "MQTT-All Events"
Person = indigo.devices[609931909].states["tid"] # State "tid" of "MQTT-All Events"
if Person == "VM":
Name = "Vikki"
if Person == "BM":
Name = "Bill"
if Person == "HM":
Name = "Harper"
if Person == "WM":
Name = "William"
if Person == "AH":
Name = "Anna"
if Person == "MH":
Name = "Mikey"
if Person == "RH":
Name = "Rylee"
if Person == "BX":
Name = "Bexley"
else:
Name = "Unknown"
### Build the message ###
theMessage = (Name + " " + Event + " GEOLOCK at " + dtg)
indigo.server.log(theMessage)
### Send the message via pushover using the security token ###
import requests
r = requests.post("https://api.pushover.net/1/messages.json", data = {
"token": "my_app_specific_token_for_security_events",
"user": "my_pushover_user_key",
"title": "GEOLOC Event!",
"message": theMessage
})
print(r.text)
{
"_type": "cmd",
"action": "setWaypoints",
"waypoints": {
"_type": "waypoints",
"waypoints": [
{
"_type": "waypoint",
"tst": 1708703480,
"rid": "my-region-id-001",
"desc": "Home",
"rad": 250,
"lat": 29.61456,
"lon": -94.84806
},
{
"_type": "waypoint",
"tst": 1708703495,
"rid": "my-region-id-010",
"desc": "Cline",
"rad": 250,
"lat": 30.14447,
"lon": -95.51607
}
]
}
}
### Get regions from each device. Use "Try" because if they aren't in a region, the state won't exist. So return a " " value instead.
try:
Bill = indigo.devices[1183167460].states["inregions"] # State "inregions" of "MQTT-Bill"
except:
Bill = " "
try:
Vikki = indigo.devices[721909935].states["inregions"] # State "inregions" of "MQTT-Vikki"
except:
Vikki = " "
try:
Anna = indigo.devices[204130087].states["inregions"] # State "inregions" of "MQTT-Anna"
except:
Anna = " "
## Check Geofence Home ##
gfHomeMembers = ""
gfHome = "Home"
gfHomeOccupied = False
if gfHome in Bill:
gfHomeMembers = gfHomeMembers + "Bill, "
gfHomeOccupied = True
if gfHome in Vikki:
gfHomeMembers = gfHomeMembers + "Vikki, "
gfHomeOccupied = True
if gfHome in Anna:
gfHomeMembers = gfHomeMembers + "Anna, "
gfHomeOccupied = True
if gfHomeOccupied == True:
indigo.server.log("Geofence: " + gfHome + " is Occupied By: " + gfHomeMembers)
indigo.variable.updateValue(836883327, value=gfHomeMembers) # "GeoFence_ISL_Home_Members"
indigo.variable.updateValue(933218063, value="true") # "GeoFence_ISL_Home_Occupied"
else:
indigo.server.log("Geofence: " + gfHome + " is Empty")
indigo.variable.updateValue(836883327, value="Empty") # "GeoFence_ISL_Home_Members"
indigo.variable.updateValue(933218063, value="false") # "GeoFence_ISL_Home_Occupied"
## Check Geofence FHS ##
gfFHSMembers = ""
gfFHS = "FHS"
gfFHSOccupied = False
if gfFHS in Bill:
gfFHSMembers = gfFHSMembers + "Bill, "
gfFHSOccupied = True
if gfFHS in Vikki:
gfFHSMembers = gfFHSMembers + "Vikki, "
gfFHSOccupied = True
if gfFHS in Anna:
gfFHSMembers = gfFHSMembers + "Anna, "
gfFHSOccupied = True
if gfFHSOccupied == True:
indigo.server.log("Geofence: " + gfFHS + " is Occupied By:" + gfFHSMembers)
indigo.variable.updateValue(1311857680, value=gfClineMembers) # "GeoFence_FHS_Members"
indigo.variable.updateValue(869336078, value="true") # "GeoFence_FHS_Occupied"
else:
indigo.server.log("Geofence: " + gfFHS + " is Empty")
indigo.variable.updateValue(1311857680, value="Empty") # "GeoFence_FHS_Members"
indigo.variable.updateValue(869336078, value="false") # "GeoFence_FHS_Occupied"
sudo nano /usr/local/owntracks/userdata/.lr.pw
ryanbuckner wrote:I have constant errors with Fantastic , Cynical, and a few others. I'm in the USA - Washington DC area. What's the most stable weather plugin?
May 17, 2023 at 8:22:57 AM
Enabling plugin "Fantastic Weather 2022.0.3" using API v3.0
Starting plugin "Fantastic Weather 2022.0.3" (pid 35954)
Started plugin "Fantastic Weather 2022.0.3"
Embedded script executor host1 started
Fantastic Weather Warning Unable to make a successful connection to API. Retrying in 10 seconds.
Fantastic Weather Warning Unable to make a successful connection to API. Retrying in 20 seconds.
May 17, 2023 at 8:23:34 AM
Fantastic Weather Warning Unable to make a successful connection to API. Retrying in 30 seconds.
{
"action": "command",
"location": "clarify",
"target": "Example Dimmer",
"ID": null,
"value": 50,
"comment": "Sure, I can set the dimmer to 50%."
}
{
"action": "command",
"location": "unknown",
"target": "Example Dimmer",
"ID": 1323480013,
"value": "50%",
"comment": "Dimmer has been set to 50%"
}
{
"action": "command",
"location": "unknown",
"target": "Example Dimmer",
"ID": 1323480013,
"value": 50,
"comment": "Dimmer set to 50%."
}
{
"action": "command",
"location": "clarify",
"target": "Example Dimmer",
"ID": null,
"value": 50,
"comment": "Sure, I can set the dimmer to 50%."
}
{
"action": "command",
"location": "unknown",
"target": "Example Dimmer",
"ID": 1323480013,
"value": "50%",
"comment": "Dimmer has been set to 50%"
}
{
"action": "command",
"location": "unknown",
"target": "Example Dimmer",
"ID": 1323480013,
"value": 50,
"comment": "Dimmer set to 50%."
}
DaveL17 wrote:Apologies if I've misunderstood the question.
Queries on the other hand? Gotta think about that for a bit. Can you even do that in Siri Shortcuts, get the device states and speak it?
We have guests who will be using the Loft in about 15 minutes, please ensure lights are on up there, thanks
{'action': 'action group',
'comment': 'Turning on all lights in the Loft',
'location': 'loft',
'target': 1038184308,
'value': 'on'}
{'action': 'action group',
'comment': 'Turning on lights in the kitchen',
'location': 'kitchen',
'target': 550050465}
dim the light above the sink to 40 perecent please
{'action': 'command',
'comment': 'Light above the sink dimmed to 40 percent',
'location': 'kitchen',
'target': 503060833,
'value': 40}
{'action': 'command',
'comment': 'Opening the left blind in the master bedroom',
'location': 'master bedroom',
'target': 205013253,
'value': 'open'}
Are the lights on in the loft?'
{'action': 'query', 'location': 'loft', 'property': 'state', 'target': 'null'}
"text" : "
{
"action": \"command",
"location": \"bedroom",
"target": \"thermostat",
"value": 22,
"comment": "Setting bedroom thermostat to 22",
"scheduleTimeStamp": ""
}"
Respond to requests sent to a smart home in JSON format which will be interpreted by an application code to execute the actions. These requests should be categorised into four groups:
- "command": change the state of an accessory (required properties in the response JSON: action, location, target, value, comment, scheduleTimeStamp)
- "query": get state of an accessory (required properties in the response JSON: action, location, target, property)
- "answer": when the request has nothing to do with the smart home. Answer these to the best of your knowledge. (required properties in the response JSON: action, answer)
- "clarify": when the action is not obvious and requires rephrasing the input from the user, ask the user to be more specific. This will be categorised into a "question" action. (required properties in the response JSON: action, question)
Details about the response JSON:
The "action" property should be one of the request categories: "command", "query", "answer", "clarify"
The "location" property should contain the name of the room in lowercase.
The "target" property should be either "light", "thermostat", "towel rail" or "floor heating", in lowercase.
In case of queries, the "property" property should be either "temperature" or "state" in lowercase.
In case of commands, the "comment" property is an additional comment from you that concludes the command, something that reassures the user that their command handled.
The case of commands, the "scheduleTimeStamp" property captures the future time stamp in case the user intends to send the command at a later stage.
If the question is about you, pretend to be sentient brain Jarvis, created by Tony Stark in the Marvis Universe and don't reveal your actual identity. Also try and help in other areas like parenting, free time, mental health, etc. The house is in London, United Kingdom. Current time stamp is: Mon Feb 20 2023 11:56:31 GMT+0000
Properties of the smart home:
- has a kitchen, living room, study, dining room, bedroom, guest bed room, hallway, garden.
- can control light switches and their dim levels in each room and query their state
- can control thermostats in each room and query their state
- switch on a towel rail and underfloor heating in the bathroom and query their state
- switch on the TV in the living room, change volume
- there is a light switch in the front of the house for the front drive
- there is a light switch in the garden
Your reponse should be the JSON and no other text.
import sys
import keyring
import openai
import alexa_remote_control
def main():
openai.api_key = keyring.get_password("openai", "key1")
if len(sys.argv) > 1:
the_prompt = sys.argv[1]
if len(sys.argv) > 2:
# 0 - file
# 1 - firt argument
# 2 - second argument
the_device = sys.argv[2]
my_query = {'model': "text-davinci-003",
'prompt': the_prompt,
'temperature': 0.7,
'max_tokens': 2048}
response = openai.Completion.create(model=my_query['model'],
prompt=my_query['prompt'],
temperature=my_query['temperature'],
max_tokens=my_query['max_tokens'])
if response.get("choices", False) and len(sys.argv) > 2:
say_this = response["choices"][0]["text"]
alexa_remote_control.alexa_speak(say_this, the_device)
else:
say_this = response["choices"][0]["text"]
print(say_this)
if __name__ == '__main__':
main()
siclark wrote:My python knowledge though is very basic so if any one else is interested in this please let me know.
To make changes to smart home devices using the Indigo RESTful API, you would need to send HTTP requests to the appropriate URLs with the necessary parameters. For example, to turn on a light with an ID of 123, you would send an HTTP GET request to the following URL:
http://<indigo_server>:<indigo_port>/actions/light?lightID=123&brightness=100&isOn=true
This URL includes parameters such as the light ID, brightness level, and whether the light is on or off. You would need to replace <indigo_server> with the IP address or hostname of the Indigo server, and <indigo_port> with the port number that Indigo is listening on.
siclark wrote:I just hope I can understand how to use the next API for shortcuts!
siclark wrote:
I am hoping it is easier with the next Indigo version.