API specification

Content

  1. Intro
  2. General Claims
  3. Response Format
  4. Authorization
  5. Energy Report Object
  6. Settings request
  7. Register User Request
  8. Delete User Request
  9. Auth Request
  10. Facebook SSO Auth Request
  11. Forgot Password Request
  12. Password Request
  13. Profile Request
  14. Change Profile Name Request
  15. Home Request
  16. Room Request
  17. Room add Request
  18. Room remove Request
  19. Devices Request
  20. Device Request
  21. Upgrade Device's Firmware Request
  22. Accept firmware update Request
  23. Device Switch Request
  24. Report Request
  25. Weather Request
  26. Register Device Request
  27. Remove Device Request
  28. Restart Device Request
  29. Get Schedule Request
  30. Set Schedule Request
  31. Tariff Request
  32. Savings Request
  33. Get Device Properties
  34. Set Device Properties
  35. Get Custom Tariff
  36. Update Custom Tariff
  37. Verify Activation Code Request
  38. Export data request
  39. Export data parameters request
  40. Set power savers request
  41. Power saver parameters request
  42. Set vacation mode request
  43. Vacation mode parameters request
  44. Add push notification token request
  45. Remove push notification token request
  46. OAuth2 authorization request
  47. OAuth2 token request
  48. Save color presets request
  49. Read color presets request
  50. Rename user request
  51. Create new scene request
  52. Update scene request
  53. Delete scene request
  54. Get scene request
  55. Execute scene request
  56. Create new action request
  57. Update action request
  58. Delete action request
  59. Get action request
  60. Set settings request

Intro

SRS project is aimed to allow user to control his energy usage. For that purpose special devices. Devices are used as adapter between outlet socket and the meausured facility.

There are 3 types of devices:

Master device serves as the local hub. It is the only device which communicate directly to SRS server.

Slave devices communicate only with master device.

SRS server currently aggregates power and consumption data as reported by master device. It also allows to turn on and off the appliance connected to the device.

SRS server also tracks device state. State can be one of the following:

General Claims

All communications is done via HTTP. UTF-8 is used in every request/response.

The request can be sent via GET or POST without difference. Parameters should be passed inside query string of the URI and should be escaped in compliance with RFC 2396.

The response is sent in JSON format as described in RFC 4627.

API is serving on /mobile/* URI prefix.

Response Format

The response is JSON object which always contains "status" field with one of the following values:

If the response status equals "error", then the response also includes "error" field, containing error code of the first error, occured during request handling.

Response error codes are predefined and will be rarely changed.

Example of the successful response:


{
    "status":"success"
}

Example of failed response:


{
    "status":"error",
    "error":"kernel.panic"
}

Authorization

Authorization is handled using authorization token. Authorization token is required to serve all private requests, containing user's private data.

Authorization token should be passed as Auth-Token HTTP header or as authToken query string parameter.

Authorization token could be acquired via auth request.

In case of unathorized attempt response with "not.authorized" error code is returned to client. Example:


{
    "status":"error",
    "error":"not.authorized"
}

Energy Report Object

Some of the responses carring energy report data contain EnergyReport object.

Example:


"energyReport":{
    "power":500.55,
    "powerColor":"#39b54a",
    "maxPower":2500.0,
    "daylyConsumption":1.5,
    "monthlyConsumption":4.5,
    "daylyCost":"10.34 Rp.",
    "monthlyCost":"100.4 Fr."
}

Description:

Settings request

Setting request is public and contains no parameters. Served on URI /mobile/settings

Response contains following settings:

Example:


{
    "status":"ok",
    "cacheTtl":"5000",
    "refreshTime":"5000"
}

Register User Request

URI - /mobile/user/register

Parameters:

Request example


https://mystrom.ch/mobile/user/register?firstname=John&lastname=Smith&email=john.smith@test.com&password=samplePassword

Response example


{
    "status":"ok"
}

Error codes:

Delete User Request

URI - /mobile/user/delete

No parameters required

Request example


https://mystrom.ch/mobile/user/delete

Response example


{
    "status":"ok"
}

Error codes:

Auth Request

Auth request is issued by client for authorization.

URI - /mobile/auth

Parameters:

Successful response contains authToken. Example:


{
    "status":"ok",
    "authToken":"0XBfQzVWRWuhNeFe-C5RWFCx9MjYjFvf2"
    ... same data as in profile response ...
}

Error codes:

Auth Request

Facebook SSO Auth request is issued by client for authorization.

URI - /mobile/auth

Parameters:

Successful response contains authToken. Example:


{
    "status":"ok",
    "authToken":"0XBfQzVWRWuhNeFe-C5RWFCx9MjYjFvf2"
    ... same data as in profile response ...
}

Error codes:

Forgot Password Request

URI - /mobile/user/forgotPassword.

Parameters:

Request example


https://mystrom.ch/mobile/user/forgotPassword?email=john.smith@test.com

Response example:


{
    "status":"ok",
}

Error codes:

Change Password Request

URI - /mobile/user/changePassword

Parameters:

Request example


https://mystrom.ch/mobile/user/changePassword?oldPassword=abc&newPassword=asd&newPasswordConfirmation=asd

Response example:


{
    "status":"ok",
}

Error codes:

Profile Request

URI - /mobile/profile.

Parameters - none.

Response contains profile data:

Response example:


{
    "status":"ok",
    "name":"Fox Malder",
    "accountType":"pro",
    "currency":"EUR",
    "onlineShop":"http://www.domadoo.fr",
    "appUrl": "http://mystrom_fr.vestiacom.com,
    "providerName":"Acqua Gas Elettricità SA Chiasso",
    "providerLogo":"http:\/\/localhost:8080\/provider_logo\/logo_81_iJca.jpg",
    "tariffName":"1to1 energy easy light",
    "tariffPrice":"CHF 22.00"
}

Note: either tariffName or tariffPrice could be defined in response, but not both (but both could be undefined). Above response serves as example to illustrate formatting of fields.

Error codes:

Change Profile Name Request

URI - /mobile/profile/name/change

Parameters:

Response example:


{
    "status":"ok"
}

Error codes:

Home Request

URI - /mobile/home

Parameters - none.

Response contains house configuration as configured by user via web ui.

Response example:


{
    "status":"ok",
    "house":{
        "rooms":[
            {
                "id":"45DcM6VpIFxH9oWg",
                "name":"Hall",
                "color":"#afe9a8",
                "devices":[
                    "000000BBBB03",
                    "0013C100D4FF"
                ]
            },
            {
                "id":"wu9U2gUnp3hojupA",
                "name":"Bath",
                "color":"#e5c4e4",
                "devices":[
                    "0013C100D51D",
                    "0013C100D511"
                ]
            }
        ],
        "energyReport":{
            "power":500.55,
            "powerColor":"#39b54a",
            "maxPower":2500.0,
            "daylyConsumption":1.5,
            "monthlyConsumption":4.5,
            "daylyCost":"10.34 Rp.",
            "monthlyCost":"100.4 CHF",
        }
    }
}

Error codes:

Room Request

URI - /mobile/room

Parameters:

Response example:


{
    "status":"ok",
    "room":{
        "id":"45DcM6VpIFxH9oWg",
        "name":"Hall",
        "color":"#afe9a8",
        "devices":[
            {
                "id":"000000BBBB03",
                "name":"Ethernet Device 3",
                "type":"eth",
                "state":"offline",
                "power":0.0,
                "powerColor":"#39b54a"
            },
            {
                "id":"0013C100D4FF",
                "name":"Ethernet Device 2",
                "type":"eth",
                "state":"offline",
                "power":0.0,
                "powerColor":"#39b54a"
            }
        ],
        "energyReport":{
            "power":100.55,
            "powerColor":"#39b54a",
            "maxPower":2500.0,
            "daylyConsumption":0.5,
            "monthlyConsumption":1.5,
            "daylyCost":"10.34 Rp.",
            "monthlyCost":"100.4 Fr."
        }
    }
}

Error codes:

Room add Request

URI - /mobile/room/add

Parameters:

Response example:


{
    "status":"ok"
}

Error codes:

Room remove Request

URI - /mobile/room/remove

Parameters:

Response example:


{
    "status":"ok"
}

Error codes:

Devices Request

Devices request is used to retrieve summary about all user's devices.

URI - /mobile/devices

Parameters

Supported types: mst, eth, sw, mtr, swg, tph

Supported minimal values: true, false

Supported timestamp formats: text, raw

Request example


https://mystrom.ch/mobile/devices
https://mystrom.ch/mobile/devices?alert&schedule&report&noRoom&totalReport
https://mystrom.ch/mobile/devices&minimal=true
https://mystrom.ch/mobile/devices&minimal=true&type=tph
https://mystrom.ch/mobile/devices&minimal=true&type=tph&timestampFormat=raw

Response example:


{
    "status":"ok",
    "devices":[
        {
            "id":"100000000003",
            "name":"Adapter 3",
            "type":"sw",
            "state":"on",
            "power":13.95,
            "powerColor":"#39b54a",
            "time":"2013-03-14 08:10:20Z",
            "deviceTypeId":"tJF1WKsm0oPinYdj",
            "deviceTypeName":"Lamp",
            "alert":{
                "enabled":true,
                "type":"power",
                "channels":["email"],
                "power":100},
            "schedule":{
                "enabled":false,
                "ranges":""},
            "energyReport": {
                "power":13.95,
                "powerColor":"#39b54a",
                "maxPower":2500.0,
                "daylyConsumption":0.023,
                "monthlyConsumption":0.023,
                "allConsumption":0.023,
                "daylyCost":"0 Rp.",
                "monthlyCost":"0 Rp.",
                "allCost":"0 Rp."},
            "room":{
                "id":"e8eRGk8kSDJEaPdR",
                "name":"Room 1",
                "color":"#a1cbe1"}
        },{
            "id":"100000000002",
            "name":"Adapter 2",
            "type":"eth",
            "state":"on",
            "power":16.43,
            "powerColor":"#39b54a",
            "time":"2013-03-14 08:10:20Z",
            "deviceTypeId":null,
            "deviceTypeName":null,
            "alert":{
                "enabled":false,
                "type":"usage",
                "channels":["email"],
                "usage":442800,
                "minutes":180},
            "schedule":{
                "enabled":false,
                "ranges":"mon 6:0 off;mon 18:0 on;tue 6:0 off;tue 18:0 on"},
            "energyReport":{
                "power":16.43,
                "powerColor":"#39b54a",
                "maxPower":2500.0,
                "daylyConsumption":3.292,
                "monthlyConsumption":11.629,
                "allConsumption":503.114,
                "daylyCost":"3 Rp.",
                "monthlyCost":"12 Rp.",
                "allCost":"5.03 CHF"},
            "room":{
                "id":"r29iGgpC8xoNurjt",
                "name":"Room 2",
                "color":"#dab32c"}
        },{
            "id":"100000000001",
            "name":"Adapter 1",
            "type":"sw",
            "state":"on",
            "power":178.2,
            "powerColor":"#39b54a",
            "time":"2013-03-14 08:10:20Z",
            "deviceTypeId":"h0Mb3IgcygBl1PzN",
            "deviceTypeName":"Computer",
            "schedule":{
                "enabled":true,
                "ranges":"mon 6:0 off;mon 10:0 on;mon 12:0 off;mon 15:0 on"},
            "scheduledSwitch":{
                "date":"2012-10-08 12:00:00Z",
                "turnOn":false},
            "energyReport":{
                "power":178.2,
                "powerColor":"#39b54a",
                "maxPower":2500.0,
                "daylyConsumption":7.833,
                "monthlyConsumption":26.416,
                "allConsumption":1082.465,
                "daylyCost":"8 Rp.",
                "monthlyCost":"26 Rp.",
                "allCost":"10.82 CHF"},
            "room":{
                "id":"vter62wPM8GXDmk1",
                "name":"Room 3",
                "color":"#87d143"}
        },{
            "id":"100000000000",
            "name":"Master",
            "type":"mst",
            "state":"on",
            "power":133.36,
            "powerColor":"#39b54a",
            "time":"2013-03-14 08:10:20Z",
            "deviceTypeId":"8IPiAjOJX8rtoWee",
            "deviceTypeName":"Audio and TV",
            "alert":{
                "type":"usage",
                "channels":["sms","email"],
                "usage":540000,
                "minutes":60},
            "schedule":{
                "enabled":false,
                "ranges":""},
            "energyReport":{
                "power":133.36,
                "powerColor":"#39b54a",
                "maxPower":2500.0,
                "daylyConsumption":16.685,
                "monthlyConsumption":50.329,
                "allConsumption":2140.834,
                "daylyCost":"17 Rp.",
                "monthlyCost":"50 Rp.",
                "allCost":"21.40 CHF"},
            "room":{
                "id":"vter62wPM8GXDmk1",
                "name":"Room 3",
                "color":"#87d143"}
        }
    ],
    "energyReport":{
        "power":341.94,
        "powerColor":"#39b54a",
        "maxPower":2500.0,
        "daylyConsumption":27.833,
        "monthlyConsumption":88.397,
        "allConsumption":3726.436,
        "daylyCost":"27 Rp.",
        "monthlyCost":"88 Rp.",
        "allCost":"37.25 CHF",
        "savings":"3.29 CHF"}
}

"room" field is optional in the response. It is present only in case of the device has the assigned room.

"alert" field is optional in the response. It is present only in case of the device has set alert.

"scheduledSwitch" field is optional in the response. It is present only in case of the device has set schedule and schedule is enabled.

Error codes:

Device Request

Device request is used to retrieve summary of device with specified id.

URI - /mobile/device

Parameters:

Supported minimal values: true, false

Supported timestamp formats: text, raw

Response example:


{
    "status":"ok",
    "device":{
        "id":"000000BBBB03",
        "name":"Ethernet Device 3",
        "type":"eth",
        "state":"online",
        "power":24.53,
		"powerColor":"#39b54a",
		"time":"2013-03-14 08:10:20Z",
        "scheduledSwitch":{
            "date":"2011-03-18 21:00:00Z",
            "turnOn":true
        },
        "energyReport":{
            "power":10.55,
            "powerColor":"#39b54a",
            "maxPower":2500.0,
            "daylyConsumption":0.1,
            "monthlyConsumption":0.5,
            "daylyCost":"10.34 Rp.",
            "monthlyCost":"100.4 Fr."
        }
    }
}

"scheduledSwitch" field is optional in the response. It is present only in case of the device scheduling rules defined. Date value passed in scheduledSwitch is expressed as UTC time Zulu.

Error codes:

here

Upgrade Device's Firmware Request

Searches for the newest firmware for device and if found firmware is newer than installed on device than upgrades it.

URI - /mobile/device/firmware/upgrade

Parameters:

Response example:


{
    "status":"ok",
}

Error codes:

Accept Firmware Upgrade Request

Method designed only for wifi buttons WBS and WBP. Should be used to apply firmware auto-upgrade on wifi buttons.

URI - /mobile/device/acceptFirmwareUpdate

Parameters:

Response example:


{
    "status":"ok",
}

Error codes:

Device Switch Request

Device switch request is used to change state of device (on, off, toggle). In case the device is bulb, it is also possible to change it's color. Parameters for color change are ignored when the device is not bulb. On and action parameters are exclusive, if both are provided then action is used. When color parameter is passed and the device is a bulb, the on|off|toggle will not take effect

When changing color (color parameter is passed) you need to provide colorMode (if none provided, default is colors). Other parameters are described below.

URI - /mobile/device/switch

Parameters:

Response example:


{
    "status":"ok",
    "state":"off"
}

Error codes:

Report Request

Report request is used to get data that can be used to draw chart.

URI - /mobile/report

Parameters:

Request example


https://mystrom.ch/mobile/report?valueType=power&periodType=week&dateFrom=2012-04-02&dateTo=2012-04-09
https://mystrom.ch/mobile/report?room=unassigned&valueType=energy&periodType=month&dateFrom=2012-04-01&dateTo=2012-05-01
https://mystrom.ch/mobile/report?room=pbBKU1Yi2OmQyGuX&valueType=cost&periodType=day&dateFrom=2012-04-01&dateTo=2012-04-02
https://mystrom.ch/mobile/report?device=000000000000&valueType=power&periodType=month&dateFrom=2012-04-01&dateTo=2012-05-01

Response example:


{
    "status":"ok",
    "chart": {
        "categories":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],
        "data": [
            null,
            null,
            {"y":0.0,"name":"0.00 W"},
            {"y":3.41,"name":"3.41 W"},
            null,
            null,
            null
        ],
        "usages": [
            {"name":"so far today","energy":"0.01 kWh","cost":"0 Rp."},
            {"name":"this month","energy":"0.09 kWh","cost":"0 Rp."},
            {"name":"all times","energy":"0.09 kWh","cost":"0 Rp."}
        ]
    }
}

Error codes:

Report Request v.2

Report request is used to get data that can be used to draw chart.

URI - /mobile/reportv2

Parameters:

Request example


https://mystrom.ch/mobile/report?valueType=power&periodType=week&dateFrom=2012-04-02&dateTo=2012-04-09
https://mystrom.ch/mobile/report?room=unassigned&valueType=energy&periodType=month&dateFrom=2012-04-01&dateTo=2012-05-01
https://mystrom.ch/mobile/report?room=pbBKU1Yi2OmQyGuX&valueType=cost&periodType=day&dateFrom=2012-04-01&dateTo=2012-04-02
https://mystrom.ch/mobile/report?device=000000000000&valueType=power&periodType=month&dateFrom=2012-04-01&dateTo=2012-05-01

Response example:


{
    "status":"ok",
    "chart": {
        "categories":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],
        "data": [
            null,
            null,
            {"y":0.0,"name":"0.00 W"},
            {"y":3.41,"name":"3.41 W"},
            null,
            null,
            null
        ],
        "usages": [
            {"name":"so far today","energy":"0.01 kWh","cost":"0 Rp."},
            {"name":"this month","energy":"0.09 kWh","cost":"0 Rp."},
            {"name":"all times","energy":"0.09 kWh","cost":"0 Rp."}
        ]
    }
}

Error codes:

Weather Request

Whether request is used to get actual weather for user's location.

URI - /mobile/weather

Parameters - none

Request example


https://mystrom.ch/mobile/weather

Response example:


{
    "status":"ok",
    "weather": {
        "symbol":"CLOUDY_PARTLY",
        "temperature":16,
        "minTemperature":8,
        "maxTemperature":16
    }
}

Symbols

Error codes:

Register Device Request

Register device request is used to register new device

URI - /mobile/device/register

Parameters:

Supported types: mst, eth, sw, mtr, swg, tph

masterId and type are required for registration not connected slave device

Request example


https://mystrom.ch/mobile/device/register?activationCode=J5HCV9EM66DA
https://mystrom.ch/mobile/device/register?userId=john.smith@srs.com&id=0013C1263D9F
https://mystrom.ch/mobile/device/register?masterId=0013C100D794&activationCode=J5HCV9EM66DA&type=eth
https://mystrom.ch/mobile/device/register?userId=john.smith@srs.com&masterId=0013C100D794&id=0013C1263D9F&type=eth

Response example:


{
    "status":"ok",
    "device": {
        "id":"000000000002",
        "name":"ECO LAN Adapter 1",
        "type":"sw",
        "state":"on",
        "power":12.15,
        "powerColor":"#39b54a"
    }
}

Error codes:

Remove Device Request

Remove device request is used to remove registered device with specified id

URI - /mobile/device/remove

Parameters:

Request example


https://mystrom.ch/mobile/device/remove?id=000000000001

Response example:


{
    "status":"ok",
}

Error codes:

Restart Device Request

Restart device request is used to restart master device

URI - /mobile/device/restart

Parameters:

Request example


https://mystrom.ch/mobile/device/restart?id=0013C100D794

Response example:


{
    "status":"ok",
}

Error codes:

Get Schedule Request

Get device schedule request is used to get schedule of device with specified id

URI - /mobile/getSchedule

Parameters:

Request example


https://mystrom.ch/mobile/getSchedule?id=000000000001

Response example:


{
    "status":"ok",
    "schedule": {
        "enabled":false,
        "ranges":"mon 3:0 off;mon 6:0 on;mon 12:0 off;mon 19:0 on"
    }
}

Error codes:

Set Schedule Request

Set device schedule request is used to set schedule of device with specified id

URI - /mobile/setSchedule

Request parameers through JSON encoded HTTP Post:

URI format


https://mystrom.ch/mobile/setSchedule

Method


POST

Example

Request


https://mystrom.ch/mobile/setSchedule

Request Body


{
    "deviceId":"000000000001",
    "schedule": {
        "enabled":false,
        "ranges":"mon 3:0 off;mon 6:0 on;fri 3:0 off;fri 10:0 on"
    }
}

Response


{
    "status":"ok",
}

Error codes:

Tariff Request

Tariff request is used to get current tariff price of user

URI - /mobile/tariff

Request example


https://mystrom.ch/mobile/tariff

Response example:


{
    "status":"ok",
    "tariff": {
        "price":"28";
    }
}

Error codes:

Savings Request

Saving request is used to get costs of current week and the prevoius week.

URI - /mobile/savings

Request example


https://mystrom.ch/mobile/savings

Response example:


{
    "status":"ok",
    "chart": {
        "now": [
            null,
            null,
            {"y":33},
            {"y":30},
            null,
            null,
            null
        ],
        "before": [
            null,
            null,
            {"y":37},
            {"y":35},
            null,
            null,
            null
        ],
    }
}

Error codes:

Get Device Properties

Get device properties request is used to get device's properties.

URI - /mobile/getDeviceProperties

Parameters:

Request example


https://mystrom.ch/mobile/getDeviceProperties?id=000000000000

Response example:


{
    "status":"ok",
    "device":{
        "id":"000000BBBB03",
        "name":"Ethernet Device 3",
        "type":"eth",
        "deviceTypeId":"8IPiAjOJX8rtoWee",
        "deviceTypeName":"Audio and TV",
        "blockSwitchingOff":false
    }
}

Value of deviceTypeName fields is in english language always.

Error codes:

Set Device Properties

Set device properties request is used to set device's properties.

URI - /mobile/setDeviceProperties

Parameters:

Request example


https://mystrom.ch/mobile/setDeviceProperties?id=000000000000&name=NewName&deviceTypeId=almth3ppmW1DZOdV

Response example:


{
    "status":"ok",
}

Error codes:

Get Custom Tariff

Fetch user's custom tariff contains peak price, off-peak price and scheduler consists ranges where peak prices are applied

URI - $/tariff/custom

Parameters - none.

Request example


https://mystrom.ch/mobile/tariff/custom

Response example:


{
    "status":"ok",
    "tariff":{
        "peakPrice":2,
        "offPeakPrice":1,
        "isPeak": true
        "schedule":[
            {"from":{"dayOfWeek":"tue","time":"06:30"},"to":{"dayOfWeek":"tue","time":"07:30"}},
            {"from":{"dayOfWeek":"wed","time":"07:00"},"to":{"dayOfWeek":"wed","time":"08:00"}},
            {"from":{"dayOfWeek":"thu","time":"10:00"},"to":{"dayOfWeek":"thu","time":"11:00"}},
            {"from":{"dayOfWeek":"fri","time":"12:00"},"to":{"dayOfWeek":"fri","time":"13:00"}},
            {"from":{"dayOfWeek":"sat","time":"14:15"},"to":{"dayOfWeek":"sat","time":"15:15"}},
            {"from":{"dayOfWeek":"sun","time":"00:00"},"to":{"dayOfWeek":"sun","time":"17:15"}},
            {"from":{"dayOfWeek":"sun","time":"17:30"},"to":{"dayOfWeek":"mon","time":"03:00"}}
        ]
    }
}

Error codes:

Update Custom Tariff

Update user's custom tariff

URI - $/tariff/custom/update

Parameters:

Range boundry format: dayOfTheWeek hour:minute

Days of the week:

Range boundry example: mon 10:30

Request example


https://mystrom.ch/mobile/tariff/custom?peakPrice=1.33&offPeakPrice=0.23&on=mon%2010:30&off=mon%2012:30&on=tue%203:30&off=tue%204:0

Response example:


{
    "status":"ok",
}

Error codes:

Verify Activation Code Request

Veryfying device's activation code

URI - $/activationCode/verify

Parameters:

Request example


https://mystrom.ch/mobile/activationCode/verify?code=R2ED-3FLY-MEHE

Response example:


{
    "status":"ok",
    "valid":true
}

Error codes:

Set export data Request

URI - $/user/exportData

Parameters:

Request example


https://mystrom.ch/mobile/user/exportData?device=SOMEMAC000&period=LAST_WEEK&granularity=EVERY_REPORT&enabled=true&now=true

Response example:


{
    "status":"ok"
}

Error codes:

Export data parameters Request

URI - $/user/exportData/parameters

Request example


https://mystrom.ch/mobile/user/exportData/parameters

Response example:


{
    "status":"ok",
    "device": "SOMEMAC0000"
    "period":"LAST_MONTH",
    "granularity": "SIXTY_SECONDS",
    "enabled": true
}

Error codes:

Set power savers Request

URI - $/device/powerSaver

Parameters:

Request example


https://mystrom.ch/mobile/device/powerSaver?device=SOMEMAC000&autoOffEnabled=true&autoOffPeriod= 1200&standbyEnabled=true&standbyThreshold=2

Response example:


{
    "status":"ok"
}

Error codes:

Power saver parameters request

URI - $/device/powerSaver/parameters

Request example


https://mystrom.ch/mobile/device/powerSaver/parameters

Response example:


{
	status: "ok"
	standbyEnabled: true
	autoOffEnabled: true
	standbyThreshold: "1.00"
	autoOffPeriod: "1"
}

Error codes:

Set vacation mode Request

URI - $/device/vacationMode

Parameters:

Request example


https://mystrom.ch/mobile/device/vacationMode?device=SOMEMAC000&enable=true

Response example:


{
    "status":"ok"
}

Error codes:

Vacation mode parameters request

URI - $/device/vacationMode/parameters

Request example


https://mystrom.ch/mobile/device/vacationMode/parameters

Response example:


{
	status: "ok"
	isVacationModeEnabled: true
}

Error codes:

Add push notification token request

URI - $/alert/addToken

Parameters:

Request example


https://mystrom.ch/mobile/alert/addToken?deviceId=0013C12620EB&alertType=turned_on&tokenType=gcm&token=APA91bEsaHpiEmVareyasLkb0PnTDioiq5xNpeZRkcCsXxPxSBwH64J0G6-7UZq-2Jc8XltYLbc3

Response example:


{
	status: "ok"
}

Error codes:

Remove push notification token request

URI - $/alert/removeToken

Parameters:

Request example


https://mystrom.ch/mobile/alert/removeToken?deviceId=0013C12620EB&alertType=turned_on&tokenType=gcm&token=APA91bEsaHpiEmVareyasLkb0PnTDioiq5xNpeZRkcCsXxPxSBwH64J0G6-7UZq-2Jc8XltYLbc3

Response example:


{
	status: "ok"
}

Error codes:

OAuth2 authorization request

URI - $/oauth2

Request example


https://mystrom.ch/mobile/oauth2?response_type=code&client_id=jan_kowalski@vestiacom.com&redirect_uri=http://google.com

Parameters:

OAuth2 token request

URI - $/oauth2/token

Request example


https://mystrom.ch/mobile/oauth2?client_id=jan_kowalski@vestiacom.com&redirect_uri=http://google.com&client_secret=4suigef8rsvpu3nlsdt0stak2q&code=251d964e43ee676a504038ac905a0a44&grant_type=authorization_code

Parameters:

Response example:


{
	token: "FDR345SDFgdfg345"
	expire_in: "365"
}

OAuth2 authorization request

URI - $/oauth2

Request example


https://mystrom.ch/mobile/oauth2?response_type=code&client_id=jan_kowalski@vestiacom.com&redirect_uri=http://google.com

Parameters:

Save color presets request

URI - $/user/saveBulbPresets

Request example


https://mystrom.ch/mobile/user/saveBulbPresets?colors=encodedColorsString

Parameters:

Response example:


{
	status: "ok"
}

Read color presets request

URI - $/user/radBulbPresets

Request example


https://mystrom.ch/mobile/user/readBulbPresets

Response example:


{
"status": "ok"
"colors": "encodedColorsString"
}

Rename user request

URI - $/user/rename

Request example


https://mystrom.ch/mobile/user/rename?email=test@srs.com&password=samplePassword

Parameters:

Response example:


{
	status: "ok"
}

Error codes:

Create new scene

URI - $/scene/create

Parameters for :

JSON Example:

    	{
		  "enabled": "true",
		  "switches":[
		    {
		    	"day":"3",
		      	"hour": "10",
		      	"minute": "25"
		    },
		    {
		    	"day":"3",
		      	"hour": "10",
		      	"minute": "27"
		    },
		    {
		    	"day":"3",
		      	"hour": "10",
		      	"minute": "29"
		    }
		  ]
		}
Acceptable values:

Request example


https://mystrom.ch/mobile/scene/create?name=newSceneName&icon=testBulbIcon

OR

https://mystrom.ch/mobile/scene/create?name=newSceneName&icon=testBulbIcon&deviceId=0013C100D65F&type=DOUBLE_PRESS&active=true

Response example:


{
	status: "ok"
}

Error codes:

Update scene

URI - $/scene/update

Parameters for :

Request example


https://mystrom.ch/mobile/scene/update

OR

https://mystrom.ch/mobile/scene/update?sceneId=OnyAC44tnNgbSJY6&name=newSceneName3&type=PRESS&deviceId=0013C100D65F&active=true

Response example:


{
	status: "ok"
}

Error codes:

Delete scene

ATTENTION! - During remove scene all actions connected with scene will be deleted!

URI - $/scene/delete

Parameters for :

Request example


https://mystrom.ch/mobile/scene/delete

OR

https://mystrom.ch/mobile/scene/delete?sceneId=sJJpqzUCir5fpOmv

Response example:


{
	status: "ok"
}

Error codes:

Get scene/scenes

URI - $/scene

Parameters for :

Request example


https://mystrom.ch/mobile/scene - returns all scenes for logged user

OR

https://mystrom.ch/mobile/scene?sceneId=134I1IlVEyBWWzpu - returns scene with sceneId from request

Response example:


{
	"status":"ok",
	"scenes":
	[
	{"sceneId":"134I1IlVEyBWWzpu","userId":"d9WarQIho2TI7SXN","deviceId":"0013C100D666","type":DOUBLE_PRESS,"name":"sceneName1","icon":"sampleBulbIcon1","active":"true"},
	{"sceneId":"1geiSN2bHgSZRbif","userId":"d9WarQIho2TI7SXN","deviceId":"SthJgXbxRvNjWYrp","type":DOUBLE_PRESS,"name":"sceneName2","icon":"sampleBulbIcon1","active":"false"},
	{"sceneId":"D8sRGD9ejoDI7otP","userId":"d9WarQIho2TI7SXN","deviceId":"0013C11F09C7","type":TOUCH,"name":"sceneName3","icon":"sampleBulbIcon2","active":"false"}
	]
}

OR

{
	"status":"ok",
	"scenes":
	[
		"sceneId":"134I1IlVEyBWWzpu","userId":"d9WarQIho2TI7SXN","deviceId":"0013C100D666","type":DOUBLE_PRESS,"name":"sceneName1","icon":"sampleBulbIcon1","active":"true"}
	]
}

Error codes:

Execute scene

URI - $/scene/execute

Parameters for :

Request example


https://mystrom.ch/mobile/scene/execute?sceneId=sJJpqzUCir5fpOmv

Response example:


{
	status: "ok"
}

Error codes:

Create new action

URI - $/action/create

Parameters for :

Request example


https://mystrom.ch/mobile/action/create?params={"action":"on","custom_parameters":{"color":"10DD10DD","saturation":"3","brightness":"100"}}&sceneId=1geiSN2bHgSZRbif&deviceId=SthJgXbxRvNjWYrp

Response example:


{
	"status":"ok"
}

Error codes:

Update action

URI - $/action/update

Parameters for :

Request example


https://mystrom.ch/mobile/action/update?params={"action":"on","custom_parameters":{"color":"10DD10DD","saturation":"3","brightness":"100"}}&actionId=KEVXSV89OF1t6PvP&sceneId=1geiSN2bHgSZRbif

Response example:


{
	"status":"ok"
}

Error codes:

Delete action

URI - $/action/delete

Parameters for :

Request example


https://mystrom.ch/mobile/action/delete?actionId=kC75dCykRgDy9BTA

Response example:


{
	"status":"ok"
}

Error codes:

Get action/actions

URI - $/action

Parameters for :

If actionId is set - returns only one action with actionId from request. If isn't - returns all actions for scene which id is on request.

Request example


https://mystrom.ch/mobile/action?actionId=kC75dCykRgDy9BTA

Response example:


{
	"status":"ok",
	"actions":[
		{
			"actionId":"jESPoKiD4WnFoaHe",
			"sceneId":"K94LUoErLbQBypmW",
			"deviceId":"SthJgXbxRvNjWYr",
			"params":"{\"key\":\"sampleValue\"}"
		}]
}

Error codes:

Set settings

URI - $/device/setSettings

Parameters for :

User should be an owner of device or should have integration permissions.

Local and cloud URLs should start with prefixes instead of HTTP of HTTPS.
For HTTPS


    posts://    <--- for POST request
    gets://     <--- for GET request

For HTTP


    post://    <--- for POST request
    get://     <--- for GET request

Request example


https://mystrom.ch/mobile/device/setSettings?id=5CCF7F0CBF12&localSingleUrl=get://sampleUrl/api/webhook/mystrom?id%3D5CCF7F2CF337%26click%3Dsingle&cloudLongUrl=posts://otherservice.com/api/doSthMethod?id=AS56GH78AhjK

Response examples:

If isBridge value is incorrect.


{
    "status":"error",
    "error":"invalid.isBridge"
}

If reportPeriod value is incorrect.


{
    "status":"error",
    "error":"invalid.report.period"
}

If heartbeatPeriod value is incorrect.


{
    "status":"error",
    "error":"invalid.heartbeat.period"
}

If device is disconnected from server and isn't a wifi button.


{
    "status":"error",
    "error":"device.not.connected"
}

If button is disconnected from server local URLs are stored and will be sent to device on the next connection.


{
    "status":"ok",
    "value":"local.URL.stored"
}

If button is connected to server local URLs are immediately sent to device.


{
    "status":"ok"
}

If request is correct but change cannot be applied on device.


{
    "status":"error",
    "error":"settings.update.failed"
}