I currently use the following script as an Server Action Execute Script for a trigger of Type Automatic OBD-II Event, Event: Approaching Home.
- Code: Select all
car = indigo.devices["Automatic OBD Audi"]
indigo.server.speak("The car is almost home at " + car.states["location"])
One way you can create a trigger based on your fuel would be to create a Trigger on Device State Changed for your device. Choose the State: vehicle, Has Any Change. Then in Condition, you could script something like:
- Code: Select all
import json
car = indigo.devices["Automatic OBD Honda"]
myVechicleJson = json.loads(car.states["vehicle"])
indigo.server.log(myVehicleJson["fuel_level_percent"])
# code to return true if fuel level is below 10%
Except, ugh, it looks like the Condition has to be Applescript and not Python??!?!?!?!! So, you'd have to do that in the Action instead of the Condition (or figure out the Applescript equivalent), and then code your action in Python. That kinda stinks.
I'll work on breaking out the useful Vehicle attributes into States.