Scene Syntax

From MiOS
Jump to: navigation, search

If you're creating your own user interface you can create a scene using JSON and send it to the engine using the scene request as described here: Luup_Requests#scene

The Json should include a name, and optionally a room. If it includes an "id" then the existing scene with that id will be overwritten. If id is blank or invalid a new scene is added.

"groups" has all the actions, where all the actions are grouped into a json object which has a given delay. In the example below 2 lights and a thermostat are controlled immediately when the scene is executed (ie delay=0), and then a light is turned off after 10 seconds.

"triggers" has the events or triggers that will cause the scene to run. "template" refers to the "eventList" in the json file for the given device type. In this example the trigger "temp_over_80" has a trigger for a thermostat (device #79), so in D_HVAC_ZoneThermostat1.json, the eventList with ID 2 is labelled "Ambient temperature goes above" and it monitors the service "urn:upnp-org:serviceId:TemperatureSensor1" and the "argumentList" for that template monitors the variable "CurrentTemperature" the "comparisson": ">" means that the value of the variable must be > than the value in the scene, so the scene will run when the temp goes over 80. For the trigger "sensor_trip" the device is a motion sensor so in D_MotionSensor1.json template #1 is "A sensor (door/window/motion/etc.) is tripped" and monitors "Tripped" and occurs when Tripped is 1. For the "leak_alarm" in D_TempLeakSensor1.json template #5 shows the trigger occurs when urn:micasaverde-com:serviceId:HaDevice1 variable sl_Alarm = WATER_LEAK, and there are no user defined arguments.

"timers" has the timers that will cause the scene to run. The types are 1=interval, 2=day of week, 3=day of month, 4=absolute. For type 2 the field "days_of_week" indicates which days of the week (Sunday=0), and for type 3 "days_of_month" is a comma-separated list of the days of the month. In both cases "time" is the time. If the time has a T or R at the end it means the time is relative to sunset or sunrise, so -1:30:0R means 1hr 30 minutes before sunrise. For type 1 the interval tag has an h or m for hours or minutes, so 1h means every 1 hour, and 30m means every 30 minutes. For type 4 the time has the day and time.

{
   "name": "Test Scene",
   "groups": [
       {
           "delay": 0,
           "actions": [
               {
                   "device": "8",
                   "service": "urn:upnp-org:serviceId:SwitchPower1",
                   "action": "SetTarget",
                   "arguments": [
                       {
                           "name": "newTargetValue",
                           "value": "1"
                       }
                   ]
               },
               {
                   "device": "9",
                   "service": "urn:upnp-org:serviceId:SwitchPower1",
                   "action": "SetTarget",
                   "arguments": [
                       {
                           "name": "newTargetValue",
                           "value": "0"
                       }
                   ]
               },
               {
                   "device": "79",
                   "service": "urn:upnp-org:serviceId:HVAC_UserOperatingMode1",
                   "action": "SetModeTarget",
                   "arguments": [
                       {
                           "name": "NewModeTarget",
                           "value": "CoolOn"
                       }
                   ]
               },
               {
                   "device": "79",
                   "service": "urn:upnp-org:serviceId:TemperatureSetpoint1_Heat",
                   "action": "SetCurrentSetpoint",
                   "arguments": [
                       {
                           "name": "NewCurrentSetpoint",
                           "value": "28"
                       }
                   ]
               }
           ]
       },
       {
           "delay": 10,
           "actions": [
               {
                   "device": "8",
                   "service": "urn:upnp-org:serviceId:SwitchPower1",
                   "action": "SetTarget",
                   "arguments": [
                       {
                           "name": "newTargetValue",
                           "value": "0"
                       }
                   ]
               }
           ]
       }
   ],
   "triggers": [
       {
           "name": "temp_over_80",
           "enabled": 1,
           "template": 2,
           "device": 79,
           "arguments": [
               {
                   "id": 1,
                   "value": "80"
               }
           ]
       },
       {
           "name": "sensor_trip",
           "enabled": 1,
           "template": 1,
           "device": 67,
           "arguments": [
               {
                   "id": 1,
                   "value": "1"
               }
           ]
       },
       {
           "name": "leak_alarm",
           "enabled": 1,
           "template": 5,
           "device": 31
       }
   ],
   "timers": [
       {
           "id": 1,
           "name": "mon_wed",
           "type": "2",
           "enabled": 1,
           "days_of_week": "1,3",
           "time": "4:9:0"
       },
       {
           "id": 2,
           "name": "after_sunset",
           "type": "2",
           "enabled": 1,
           "days_of_week": "",
           "time": "+1:0:0T"
       },
       {
           "id": 3,
           "name": "New schedule",
           "type": 1,
           "enabled": 1,
           "interval": "5h"
       }
   ],
   "id": 20,
   "room": 0
}
Personal tools