Urllib2 Read Only a Certain Amount of Text
Domoticz allows y'all to interact with all your switches and sensors using JSON, either interactively through a browser or programmatically from a scripting linguistic communication. In fact, when you lot interact with the Domoticz UI through your browser past clicking on buttons and such, under the hood it's JSON that actually communicates your changes dorsum to the Domoticz engine (Hint: Y'all tin can sentinel this behaviour at any time past enabling developer tools in your browser and watching the network tab's traffic when you lot change something through the UI. See the section on changing a zwave device parameter for an case, with screenshot). This wiki describes how to utilize this versatile API.
Format
http://<username:[e-mail protected]>domoticz-ip<:port>/json.htm?api-call
- <username:[e-mail protected]> = the username and password to access Domoticz, this is optional.
- domoticz-ip = the IP-address or hostname of your Domoticz installation.
- <:port> = the port number of your Domoticz installation, this is optional.
eg. http://192.168.ane.2:8080/json.htm?type=command¶m=udevice&idx=$idx&nvalue=0&svalue=79
Hint: Yous can accept a look at the database for the nValue/sValue, or the .cpp code.
Making output more readable
By default, your browser volition display the JSON-output in a unordered mess. To brand it more readable you could use a browser plugin that formats the JSON to a more human-readable layout.
For Google Chrome you could use JSONView (Chrome spider web store). For other browsers a similar extension will probably exist. Look in the extensions/add-on store of your browser.
There are online sites which helps to do the same like https://jsonformatter.org. This site helps to format, tree view and validate JSON.
When using some method other than a browser to connect to Domoticz it may be necessary to do Potency differently. Potency over HTTP is done by setting the "Authorization" HTTP asking header when sending the request to Domoticz. The value of this header is a base64 encoded string of the username and password. When connecting to Domoticz using a browser and the URL method above the browser sets the appropriate header. When creating your own app or script this is not e'er done for you.
- First the username and password are combined into i string "username:password"
- This string is encoded using the RFC2045-MIME version of base64
- The authorization method and a infinite i.e. "Bones " is then put before the encoded cord.
This results in a header in the following format:
Au t horiza t io n : Bones QWxhZGRpbjpvcGVuIHNlc 2 F t ZQ== How the header is send differs per programming language. Bank check the documentation of the language of your choice on how to set http asking headers.
This method works with both the Basic-Auth and Login page options.
Authority with parameters
An other mode to set username and countersign when calling the API is:
http://domoticz-ip<:port>/json.htm?username=MkE=&countersign=OVM=&api-call
- MkE= is the base64 encoded username ('2A' in this instance)
- OVM= is the base64 encoded password ('9S' in this example)
Users
When you use an user and password in this api, the user must take "user" or "admin" rights. Come across also page User Management
The user too must have the right to access the device (see 'Ready Devices' in Edit Users page).
Base64 encode
To encode a string using base64 you could use: codebeautify.org/base64-encode
Response
All responses include a status which is either OK on success or ERR on failure
General usage
Delight annotation that many characters are non permitted in URL strings, including spaces, brackets, etc. Depending on which options below y'all are using, it may exist necessary to URL encode the string first. This is as well called URI-encoding, escaping or per centum-encoding. See URL encode/decode.
Equally an example, the string:
This is a test ! (Really)
when properly encoded, looks similar this
This%20is%20a%20test%twenty%21%twenty%28Really%29
It'south as well commanded to employ a '+' instead of '%20' to encode spaces (this is normally reserved for HTML forms processing just Domoticz accepts both).
A notation on IDXes
At that place are different categories of IDX values, such as for devices, for scenes, for timers, for hardware devices, etc. Brand sure that you are using the right IDX value when trying the commands below. Device IDXes can be found by looking at the Setup --> Devices tab in the UI. Similarly, Setup --> Hardware will list the hardware category IDXes. See the department(s) on scenes and timers/schedules below to see how to retrieve their particular IDXes or timerIDs using JSON.
Retrieve status of Domoticz example
You can go the status of a Domoticz instance with:
/json.htm?type=control¶m=getversion
{ "DomoticzUpdateURL" : "http://world wide web.domoticz.com/download.php?channel=beta&type=release&system=linux&machine=armv7l" , "HaveUpdate" : simulated , "Revision" : 9540 , "SystemName" : "linux" , "UseUpdate" : true , "build_time" : "2018-05-29 fourteen:27:24" , "dzvents_version" : "2.4.vi" , "hash" : "30295913" , "python_version" : "three.v.3 (default, Jan nineteen 2017, 14:xi:04) \n[GCC half-dozen.3.0 20170124]" , "status" : "OK" , "title" : "GetVersion" , "version" : "3.9530" } Get list of all defined users in the organization
/json.htm?type=users
{ "result" : [ { "Enabled" : "truthful" , "Password" : "abcdef1234567890abcdef1234567889" , "RemoteSharing" : i , "Rights" : ii , "TabsEnabled" : 127 , "Username" : "waaren" , "idx" : "2" }, { "Enabled" : "truthful" , "Password" : "abcdef1234567890abcdef1234567889" , "RemoteSharing" : 0 , "Rights" : 2 , "TabsEnabled" : 0 , "Username" : "IFTTTx" , "idx" : "iii" }, ], "status" : "OK" , "championship" : "Users" } Become settings
/json.htm?type=settings
This volition return the settings defined in "Setup" under a JSON class. For ex.:
{ "AcceptNewHardware" : 0 , "ActiveTimerPlan" : 0 , "ClickatellEnabled" : "" , "ClickatellFrom" : "" , "ClickatellPassword" : "" , ... } Retrieve Domoticz logfile information
You lot can become the last couple (fixed at max. 100) of logmessages with:
/json.htm?type=command¶m=getlog&lastlogtime=LASTLOGTIME&loglevel=LOGLEVEL
LOGLEVEL 1 = normal 2 = status 4 = error 268435455 = all
LASTLOGTIME starting with logmessages in LASTLOGTIME seconds since final epoch ( 0 = all available)
{ "LastLogTime" : "1615579727" , "upshot" : [ { "level" : 4 , "message" : "2021-03-12 17:11:47.613 Mistake: BuienRadar: Trouble Connecting to Buienradar! (Check your Internet Connection!)" }, { "level" : 4 , "message" : "2021-03-12 18:30:05.598 Error: dzVents: Fault: (three.ane.vi) openUV: /opt/domoticz/scripts/dzVents/scripts/openUV.lua:63: attempt to index a nil value (field 'upshot')" }, { "level" : 4 , "message" : "2021-03-12 21:08:47.542 Error: (Evohome) status request failed with bulletin: Timeout was reached" } ], "condition" : "OK" , "title" : "GetLog" } Add together a log message to the Domoticz log
Yous can add a log message to the organisation with:
/json.htm?type=command¶m=addlogmessage&bulletin=MESSAGE&level=LEVEL
- MESSAGE = a string yous want to log. Make sure to URL-encode whatever dangerous not-alphanumeric characters. Run into URL encode/decode
"LEVEL" 1 = normal // default
two = status 4 = error
{ "status" : "OK" , "title" : "AddLogMessage" } Retrieve condition of specific device
You can get the status of a specific device with:
/json.htm?type=devices&rid=IDX
- IDX = id of your device (This number tin can be found in the devices tab in the column "IDX")
{ "ActTime" : 1613058183 , "AstrTwilightEnd" : "19:39" , "AstrTwilightStart" : "06:06" , "CivTwilightEnd" : "18:twenty" , "CivTwilightStart" : "07:24" , "DayLength" : "09:46" , "NautTwilightEnd" : "nineteen:00" , "NautTwilightStart" : "06:45" , "ServerTime" : "2021-02-eleven xvi:43:03" , "SunAtSouth" : "12:52" , "Sunrise" : "08:00" , "Sunset" : "17:45" , "app_version" : "2020.two (build 12936)" , "result" : [ { "AddjMulti" : i , "AddjMulti2" : 1 , "AddjValue" : 0 , "AddjValue2" : 0 , "BatteryLevel" : 255 , "CustomImage" : 0 , "Data" : "On" , "Description" : "Plain text" , "DimmerType" : "none" , "Favorite" : 0 , "HardwareDisabled" : faux , "HardwareID" : iii , "HardwareName" : "virtual" , "HardwareType" : "Dummy (Does nil, utilize for virtual switches just)" , "HardwareTypeVal" : 15 , "HaveDimmer" : true , "HaveGroupCmd" : true , "HaveTimeout" : false , "ID" : "00014052" , "Paradigm" : "Light" , "IsSubDevice" : false , "LastUpdate" : "2021-02-ten 22:47:03" , "Level" : 0 , "LevelInt" : 0 , "MaxDimLevel" : 100 , "Name" : "mySwitch" , "Notifications" : "false" , "PlanID" : "0" , "PlanIDs" : [ 0 ], "Protected" : false , "ShowNotifications" : truthful , "SignalLevel" : "-" , "Status" : "On" , "StrParam1" : "" , "StrParam2" : "" , "SubType" : "Switch" , "SwitchType" : "On/Off" , "SwitchTypeVal" : 0 , "Timers" : "false" , "Blazon" : "Light/Switch" , "TypeImg" : "lightbulb" , "Unit" : i , "Used" : 1 , "UsedByCamera" : false , "User" : "Admin (IP: 192.168.192.41)" , "XOffset" : "0" , "YOffset" : "0" , "idx" : "2" } ], "status" : "OK" , "title" : "Devices" } - The array result[0] contains a hash/dict with name/value pairs of settings that are relevant to the device in question, in this example a thermostat.
- Please note that it will be something like json.result[1] in archetype Lua and dzVents script considering in Lua an array starts with 1.
Retrieve name / idx of all devices
If you are not certain of the IDX and want to practise a quick lookup of name/value pairs to match a device name to its IDX, use
/json.htm?type=command¶m=devices_list
which volition issue in something like (fragment)
{ "name" : "Corner Light" , "value" : "156" }, { "proper name" : "Table Low-cal" , "value" : "198" }, Become status of all devices of a certain type
/json.htm?type=devices&filter=all&used=true&club=Name
This volition return information about all used devices. If you want to think data for a specific devicetype, you can use the following filters with &filter=:
low-cal weather temp utility wind rain uv baro zwavealarms
{ "ActTime" : 1615581479 , "AstrTwilightEnd" : "20:34" , "AstrTwilightStart" : "05:09" , "CivTwilightEnd" : "nineteen:xv" , "CivTwilightStart" : "06:29" , "DayLength" : "11:39" , "NautTwilightEnd" : "19:54" , "NautTwilightStart" : "05:50" , "ServerTime" : "2021-03-12 21:37:59" , "SunAtSouth" : "12:52" , "Sunrise" : "07:02" , "Dusk" : "18:41" , "app_version" : "2020.ii (build 13065)" , "result" : [ { "List of all devices" : one } ], "status" : "OK" , "title" : "Devices" } /json.htm?type=devices&used=truthful&displayhidden=i
Device names starting with a '$' sign are invisible in both the Dashboard and Switches tabs in the Domoticz UI. If you want these devices included in the json output then displayhidden must be specified.
{ "ActTime" : 1615641865 , "AstrTwilightEnd" : "twenty:36" , "AstrTwilightStart" : "05:07" , "CivTwilightEnd" : "19:16" , "CivTwilightStart" : "06:26" , "DayLength" : "11:43" , "NautTwilightEnd" : "19:56" , "NautTwilightStart" : "05:47" , "ServerTime" : "2021-03-xiii 14:24:25" , "SunAtSouth" : "12:51" , "Sunrise" : "07:00" , "Sunset" : "eighteen:43" , "app_version" : "2020.2 (build 13065)" , "result" : [ { "AddjMulti" : 1 , "AddjMulti2" : one , "AddjValue" : 0 , ... "Proper name" : "$Harmony_Mediacenter" , "Notifications" : "false" , "PlanID" : "0" , ... "YOffset" : "0" , "idx" : "2176" }, ], "status" : "OK" , "title" : "Devices" } Get status of all Favorite devices
/json.htm?type=devices&used=true&filter=all&favorite=i
This will render simply devices that are tagged as Favorite.
Get server time
/json.htm?blazon=command¶m=getServerTime
{ "ServerTime" : "2021-01-13 23:10:13" , "status" : "OK" , "title" : "getServerTime" } Get sunrise and sunset times
/json.htm?type=control¶m=getSunRiseSet
{ "ServerTime" : "Sep thirty 2013 17:15:21" , "Sunrise" : "07:38:00" , "Sunset" : "19:sixteen:00" , "status" : "OK" , "title" : "getSunRiseSet" } Use Notification Subsystem
You can mail service a notification to all enabled notification systems with:
/json.htm?type=command¶m=sendnotification&field of study=Discipline&body=THEBODY
{ "status" : "OK" , "title" : "SendNotification" } You can as well post a notification to one or more notification systems with:
/json.htm?type=control¶m=sendnotification&subject=SUBJECT&body=THEBODY&subsystem=SUBSYSTEM1;SUBSYSTEM2;...
- SUBJECT = a cord y'all want to use equally subject area
- THEBODY= a string you want to apply as torso
- SUBSYSTEM= the notification arrangement(s) you lot want to use (lowercase)
fcm http kodi lms nma cruise pushalot pushbullet pushover pushsafer
transport a VACUUM request to domoticz database; sqlite.org: "The VACUUM command rebuilds the database file, repacking information technology into a minimal corporeality of disk infinite "
Please note that this command does crave free space on the used temporary file organisation up to twice the current databases size.
Encounter [sqlite.org ] goto 5.Temporary File Storage Locations
json.htm?type=command¶m=vacuumdatabase { "condition" : "OK" , "title" : "VacuumDatabase" } this phone call will create a database backup in the download directory of your workstation.
Outcome system
Get overview of (internal) events
/json.htm?type=events¶m=list { "interpreters" : "Blockly:Lua:dzVents:Python" , "consequence" : [ { "eventstatus" : "0" , "id" : "77" , "name" : "Lua pinger" }, { "eventstatus" : "0" , "id" : "106" , "name" : "Lua coil" }, .... } ], "status" : "OK" , "title" : "ListEvents" } /json.htm?type=events¶m=updatestatus&eventid=77&eventstatus=1 { "status" : "OK" , "title" : "Events" } Accept new sensors
/json.htm?type=control¶m=allownewhardware&timeout=MINUTES { "status" : "OK" , "championship" : "AllowNewHardware" } Lights and switches
Get details of all lights/switches
/json.htm?type=control¶m=getlightswitches
OR
/json.htm?type=devices&filter=calorie-free&used=truthful&lodge=Name
Case output:
{ "result" : [ { "IsDimmer" : false , "Name" : "Bedroom lights" , "SubType" : "Energenie" , "Type" : "Lighting 1" , "idx" : "43" }, { "IsDimmer" : false , "Name" : "Hall" , "SubType" : "Energenie" , "Type" : "Lighting i" , "idx" : "30" }, { "IsDimmer" : true , "Proper noun" : "Lounge Light Front" , "SubType" : "RGBW" , "Type" : "Lighting Limitless/Applamp" , "idx" : "32" }, { "IsDimmer" : truthful , "Name" : "Lounge Lights All" , "SubType" : "RGBW" , "Type" : "Lighting Limitless/Applamp" , "idx" : "66" }, { "IsDimmer" : truthful , "Name" : "Lounge light back" , "SubType" : "RGBW" , "Type" : "Lighting Limitless/Applamp" , "idx" : "33" } ], "status" : "OK" , "title" : "GetLightSwitches" } Turn a calorie-free/switch on/off
/json.htm?blazon=command¶m=switchlight&idx=99&switchcmd=<On|Off|Toggle|End>
{ "condition" : "OK" , "title" : "SwitchLight" } When mistake:
{ "message" : "Error sending switch control, check device/hardware (idx=nnn) !" , "condition" : "Fault" , "title" : "SwitchLight" } Besides valid for Blinds, Close/Open should be converted to On/Off. For Inverted blinds the On/Off pregnant is Inverted. For Venetian Blinds: Finish command is &switchcmd=End.
Commands are example sensitive!
Beware that if the switch has the 'protected' attribute set then you demand add fundamental `passcode` (with the right passcode)
/json.htm?type=control¶m=switchlight&idx=99&switchcmd=Off&passcode=YOUR_SWITCH_PASSWORD_AS_SET_IN_SETTINGS
or the condition will exist
{ "message" : "WRONG CODE" , "status" : "Mistake" , "title" : "SwitchLight" } Notation that when you use &switchcmd, the http:// or script:// on/off deportment of the corresponding switch are executed. If you merely want to update the status of the switch in Domoticz without running these actions, utilise the ¶m=udevice option instead (run into update-section below).
Switching Blinds sun/wind detector on/off
On some type of blinds it is possible to eneble disable the sun/current of air detector.
Enable (where the number backside idx is the idx number of the screen in domoticz):
/json.htm?type=command¶m=switchlight&idx=7&switchcmd=EnableSunWind
Disable:
/json.htm?blazon=command¶m=switchlight&idx=7&switchcmd=DisableSunWind
Gear up a dimmable light/blinds/selector to a sure level
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=Set%20Level&level=vi
- dimmable:
- Some lights have 100 dim levels (similar zwave and others), other hardware (kaku/lightwaverf) take other ranges similar sixteen/32
- Level should exist the dim level (not percentage), similar 0-16 or 0-100 depending on the hardware used
- When the light is off, it will be turned on
- Blinds: enter percentage, level will be 0-100
- Selector switch: enter the level number (eg ten, 20 or xxx) that can be found in the edit section of a switch.
- To update in Domoticz just without running it's device actions apply
/json.htm?type=control¶m=udevice&idx=IDX&nvalue=[0,1,2]&svalue=LEVELNRStatuses for Blinds Percentage when using ¶m=udevice:
Airtight: nValue = 1 and sValue = 100 partially opened: nValue = 2 and sValue = 1-99 Open up: nValue = 0 and sValue = 0
{ "status" : "OK" , "title" : "SwitchLight" } Set a lite to a certain color or color temperature
Color tin can be specified as either hue + brightness, RGB + optional effulgence or a Domoticz JSON color object
- Specify hue and brightness
- Hue in degrees, 0..360
- Brightness 0..100
/json.htm?type=control¶m=setcolbrightnessvalue&idx=99&hue=274&effulgence=twoscore&iswhite=faux
{ "status" : "OK" , "title" : "SetColBrightnessValue" } - Note: In that location is no saturation parameter, specify RGB format Domoticz JSON color format for total color control
- Specify RGB and effulgence (optional)
- RGB as hexadecimal number, RRGGBB without prefix (no 0x or #)
/json.htm?type=command¶m=setcolbrightnessvalue&idx=99&hex=RRGGBB&brightness=100&iswhite=fake
{ "status" : "OK" , "championship" : "SetColBrightnessValue" } - Note: The actual effulgence of the light is a combination of RGB value and brightness. Brightness parameter may be omitted.
- A site similar colorhexa can be used to help pick hex values according to desired colours.
- Specify Domoticz JSON color object and brightness
- Instance: Specify colour mode with a dim blue colour
/json.htm?type=control¶m=setcolbrightnessvalue&idx=130&color={"grand":3,"t":0,"r":0,"grand":0,"b":50,"cw":0,"ww":0}&brightness=100 { "status" : "OK" , "championship" : "SetColBrightnessValue" } Domoticz color format:
Domoticz color format is used every bit:
- input parameter to:
- - setcolbrightnessvalue
- - updatetimer
- - addtimer
- - addscenedevice
- - updatescenedevice
- In response from:
- - devices
- - getscenedevices
- - timers
Example: color={"m":three,"t":0,"r":0,"g":0,"b":l,"cw":0,"ww":0}
ColorMode { ColorModeNone = 0, // Illegal ColorModeWhite = 1, // White. Valid fields: none ColorModeTemp = two, // White with color temperature. Valid fields: t ColorModeRGB = 3, // Colour. Valid fields: r, chiliad, b. ColorModeCustom = 4, // Custom (color + white). Valid fields: r, one thousand, b, cw, ww, depending on device capabilities ColorModeLast = ColorModeCustom, }; Color { ColorMode one thousand; uint8_t t; // Range:0..255, Color temperature (warm / cold ratio, 0 is coldest, 255 is warmest) uint8_t r; // Range:0..255, Ruby level uint8_t g; // Range:0..255, Dark-green level uint8_t b; // Range:0..255, Bluish level uint8_t cw; // Range:0..255, Cold white level uint8_t ww; // Range:0..255, Warm white level (besides used as level for monochrome white) } References This API call is called internally by dzVents when using the following device object methods:
- setColor(r, grand, b, br, cw, ww, m, t)
- setColorBrightness()
Please ensure local access is enabled for 127.0.0.1 or 127.0.0.* (described here). for these to piece of work correctly.
The parameters r, one thousand, b, cw, ww, k and t map to the same values in the same color object.
The parameter br maps to effulgence [0..100].
Set up an RGB_CW_WW or CW_WW light to a sure color temperature
/json.htm?blazon=control¶m=setkelvinlevel&idx=99&kelvin=1
{ "condition" : "OK" , "title" : "Fix Kelvin Level" } Range of kelvin parameter: 0..100, 0 is coldest, 100 is warmest
References This API call is chosen internally past dzVents when using the following device object method:
- setKelvin(Kelvin)
Please ensure local access is enabled for 127.0.0.1 or 127.0.0.* (described here). for this to work correctly.
Toggle a switch state betwixt on/off
/json.htm?type=control¶m=switchlight&idx=99&switchcmd=Toggle
{ "status" : "OK" , "championship" : "SwitchLight" } Cameras
Get cameras
/jso n .h t m? t ype=cameras { "outcome" : [ { "Address" : "192.168.192.111" , "Enabled" : "true" , "ImageURL" : "prototype.jpg" , "Name" : "Inside" , "Password" : "Secret" , "Port" : 19767 , "Protocol" : 0 , "Username" : "anyUser" , "idx" : "1" }, { "Address" : "192.168.192.112" , "Enabled" : "truthful" , "ImageURL" : "image.jpg" , "Proper noun" : "Outside" , "Password" : "verySecret" , "Port" : 19765 , "Protocol" : 0 , "Username" : "anotherUser" , "idx" : "2" } ], "status" : "OK" , "title" : "Cameras" } Add together camera
imageurl must be base64 encoded &user&countersign optional
/jso n .h t k? t ype=comma north d¶m=addcamera&accost= 192.168.192.111 &por t = 19765 & na me=i ns ideCamera&eastward na bled= truthful &imageurl=aW 1 hZ 2 Uua n B n &pro t ocol= 0 { "status" : "OK" , "championship" : "AddCamera" } Update camera
imageurl must be base64 encoded &user&countersign optional
/jso n .h t m? t ype=comma n d¶m=upda te photographic camera&address= 192.168.192.111 &por t = 19767 & na me= test &e na bled= truthful &idx= 1 &imageurl=aW 1 hZ ii Uua due north B due north &pro t ocol= 0 { "status" : "OK" , "championship" : "UpdateCamera" } Send snapshot from camera
imageurl must be base64 encoded
&user&countersign optional
Sends email with a camera snapshots if email is configured in Bill of fare Setup - Settings and set for attachments.
camidx: Send 1 or multiple camerIDs in ; separated.
Subject: Subject of email
/jso north .h t m? t ype=comma n d¶m=emailcameras na psho t &camidx= one ; 3 &subjec t =Moveme nt +a t +Fro nt door { "status" : "OK" , "title" : "Electronic mail Camera Snapshot" } Scenes / Groups
Get electric current state of all scenes & groups
/json.htm?blazon=scenes
Case output:
{ "event" : [ { "Favorite" : 1 , "HardwareID" : 0 , "LastUpdate" : "2013-09-29 19:11:01" , "Name" : "My Scene" , "Condition" : "Off" , "Timers" : "true" , "Blazon" : "Scene" , "idx" : "nine" }, { "Favorite" : one , "HardwareID" : 0 , "LastUpdate" : "2013-09-thirty 11:49:13" , "Proper noun" : "My Group" , "Status" : "Off" , "Timers" : "false" , "Type" : "Grouping" , "idx" : "3" } ], "status" : "OK" , "title" : "Scenes" } Plow a scene / group on or off
/json.htm?type=control¶m=switchscene&idx=&switchcmd=
- idx = id of your scene/grouping.
- switchcmd = "On", "Off" or "Toggle" (case sensitive!)
- Scenes can just be turned On
{ "status" : "OK" , "championship" : "SwitchScene" } Add a scene (0)
/json.htm?type=addscene&proper name=scenename&scenetype=0
Add a group (ane)
/json.htm?blazon=addscene&proper noun=scenename&scenetype=1
Delete a scene or grouping
/json.htm?type=deletescene&idx=number
List devices in a scene
/json.htm?type=command¶m=getscenedevices&idx=number&isscene=truthful
Add device to a scene
/json.htm?type=command¶m=addscenedevice&idx=number&isscene=true&devidx=deviceindex&command=1&level=number&hue=number
Delete device from a scene
/json.htm?blazon=command¶m=deletescenedevice&idx=number
Listing activation devices of a scene
/json.htm?type=control¶m=getsceneactivations&idx=number
Case output:
{ "result" : [ { "code" : 0 , "codestr" : "-" , "idx" : 249 , "name" : "Activator device" }, { "code" : 0 , "codestr" : "-" , "idx" : 1048 , "proper name" : "Another Activator device" } ], "status" : "OK" , "title" : "GetSceneActivations" } Add activation devices for a scene
/json.htm?type=command¶m=addscenecode&sceneidx=<scene ID>&idx=<device ID>&cmnd=<command>
Example output:
{ "status" : "OK" , "title" : "AddSceneCode" } Add together OnAction and OffAction to a scene or group
This command can be result only after a scene or grouping was created, so first create the scene/group, than update the scene/group specifying the On Activity and/or Off Activity
/json.htm?blazon=updatescene&idx=number&scenetype=scenetype&onaction=base64onaction&offaction=base64offaction
where number is the idx of the scene/grouping, scenetype is 0 for scenes of ane for groups, base64onactions is the On Action coded with base64 and base64offaction is the Off Action coded with base64. It's possible to notice base64 converters online, similar https://www.base64encode.org/
Please note that you have to include your electric current description if any
Example output:
{ "condition" : "OK" , "title" : "UpdateScene" } List timers of a scene
/json.htm?blazon=scenetimers&idx=number
Example output:
{ "event" : [ { "Active" : "true" , "Cmd" : 0 , "Date" : "07-02-2016" , "Days" : 128 , "Hue" : 0 , "Level" : 100 , "Randomness" : true , "Time" : "00:01" , "Blazon" : five , "idx" : "sixteen" } ], "condition" : "OK" , "title" : "SceneTimers" } Add together timer to a scene
/json.htm?type=control¶m=addscenetimer&idx=number&active=&timertype=&date=&60 minutes=&min=&randomness=&control=&level=&days=
- idx = index of your scene/group.
- agile = true/imitation
- timertype = 0 = Before Sunrise, 1 = After Sunrise, 2 = On Time, 3 = Before Sunset, iv = Afterwards Sunset, five = Fixed Appointment/Fourth dimension
- date = MM-DD-YYYY
- hour = 60 minutes
- min = minute
- randomness = true/false
- command = On/Off
- level = 0..100 (%)
- days = 0x80 = Everyday, 0x100 = Weekdays, 0x200 = Weekends, 0x01 = Mon, 0x02 = Tue, 0x04 = Wed, 0x08 = Thu, 0x10 = Friday, 0x20 = Sat, 0x40 = Sun
Enable/disable/delete specific scene schedule(timer)
Enable specific schedule(timer) for Scenes/Groups
Disable specific schedule(timer) for Scenes/Groups
Delete specific schedule(timer) for Scenes/Groups
Thermostat control
Set Setpoint
/json.htm?type=command¶m=setsetpoint&idx=&setpoint=
- idx = id of the thermostat
- setpoint = value in Celsius (like 20.5)
Server control
Shutdown organisation
/json.htm?type=command¶m=system_shutdown
{ "status" : "OK" , "title" : "SystemShutdown" } Reboot system
/json.htm?type=command¶m=system_reboot
{ "status" : "OK" , "championship" : "SystemReboot" } Create, delete, rename, action and disable commands
Create virtual hardware
/json.htm?type=command¶m=addhardware&htype=15&port=1&name=Sensors1&enabled=true
later to get the id, either you have your last created id from an index you maintain or sort the hardware page for last ID:
/json.htm?type=hardware
Create a virtual sensor
Bones action (see below for values)
/json.htm?type=createvirtualsensor&idx=HWIDX&sensorname=SENSORNAME&sensortype=SENSORTYPE
Note: It is unremarkably easier to utilize the CreateDevice JSON (see next section)
Temp+Humidity example
/json.htm?type=createvirtualsensor&idx=HWIDX&sensorname=TempHum&sensortype=82
Electricity example
/json.htm?type=createvirtualsensor&idx=HWIDX&sensorname=Free energy&sensortype=90
and then go the device id from the listing:
/json.htm?type=devices&filter=all&used=true&society=Name
Values:
- HWIDX = id of your (Dummy) hardware (not the device!). This number tin can be found in the hardware tab in the cavalcade "IDX".
Note: If a non existing hardware IDX is used the created device is greyed out in the user interface!
- SENSORNAME = sensor name
- SENSORTYPE = See list below (this is an incomplete listing. For more devices come across page Developing a Python plugin)
1 Pressure (Bar) 0.0 nvalue=BAR (TBC) two Pct 0.0 nvalue=Percent (TBC) 80 TEMP 0.0 svalue=TEMP 81 HUM ane nvalue=HUM svalue=1 to 3 82 TEMP_HUM 0.0;50;ane svalue=TEMP;HUM;HUM_STATUS 84 TEMP_HUM_BARO 0.0;l;1;1010;1 svalue=TEMP;HUM;HUM_STATUS;BARO;BARO_FCST 85 Pelting 0;0 svalue=RAIN;Rain in mm/h 86 Wind 0;N;0;0;0;0 svalue=WIN_SPD;WIND_DIR;?;?;?;? 87 UV 0;0 svalue= (TBC) 113 RFXMeter 0 Can have several values, another gild has to be sent to prepare the sub type: blazon 5 Time: svalue=COUNTER type 4 Energy generated: svalue=POWER;Energy type 3 Counter: svalue=COUNTER type 2 H2o: svalue=VOLUME type 1 Gas: svalue=Book blazon 0 Energy: svalue=POWER;ENERGY 90 ENERGY 0;0.0 svalue=Ability;Energy 249 TypeAirQuality 0 nvalue=PPM
For the RFXMeter some other request is needed to set the utility (switchtype). URL is:
/json.htm?blazon=setused&idx=DEVICE_IDX&name=SENSORNAME&switchtype=SUBTYPE_VALUE&used=true
where DEVICE_IDX is the device idx, SENSORNAME is device name, and the SUBTYPE_VALUE is one of:
0 for Energy 1 for Gas 2 for Water three for Custom Counter 4 for Energy Generated 5 for Time
Create a device
An overview of all available devices can be found in wiki folio Developing_a_Python_plugin#Available_Device_Types
Bones Action:
/json.htm?type=createdevice&idx=HWIDX&sensorname=SENSORNAME&devicetype=DEVICETYPE&devicesubtype=DEVICESUBTYPE
- HWIDX = id of your (Dummy) hardware. This number can be establish in the hardware tab in the column "IDX".
Note: If a non existing hardware IDX is used the created device is greyed out in the user interface!
- SENSORNAME = sensor name
- DEVICETYPE = type of device, see overview Developing_a_Python_plugin#Available_Device_Types
Source: https://github.com/domoticz/domoticz/blob/development/hardware/hardwaretypes.h or https://github.com/domoticz/domoticz/blob/development/main/RFXtrx.h
- DEVICESUBTYPE = subtype of device, see overview Developing_a_Python_plugin#Available_Device_Types
Source: https://github.com/domoticz/domoticz/hulk/evolution/hardware/hardwaretypes.h or https://github.com/domoticz/domoticz/hulk/development/main/RFXtrx.h
Case Consequence
{ "idx" : "142" , "status" : "OK" , "championship" : "CreateSensor" } Examples:
Temp (Type: pTypeTEMP, subType: sTypeTEMP5)
/json.htm?type=createdevice&idx=HWIDX&sensorname=Temp5&devicetype=50&devicesubtype=5
Voltage (Type: pTypeGeneral, subType: sTypeVoltage)
/json.htm?type=createdevice&idx=HWIDX&sensorname=Voltage0&devicetype=243&devicesubtype=8
Electric (Instant+Counter)
/json.htm?type=createdevice&idx=HWIDX&sensorname=ElecInstCount&devicetype=243&devicesubtype=29
Counter Incremental
/json.htm?blazon=createdevice&idx=HWIDX&sensorname=Counter%20Increment2&devicetype=243&devicesubtype=28
For the Counter Incremental, Counter and managed Counter and Switches another request is needed to set the type(switchtype). URL is:
/json.htm?type=setused&idx=DEVICE_IDX&name=SENSORNAME&switchtype=SUBTYPE_VALUE&used=true
where for counters DEVICE_IDX is the device idx, SENSORNAME is device name, and the SUBTYPE_VALUE is one of:
0 for Energy 1 for Gas two for Water three for Custom Counter 4 for Energy Generated five for Time
For switches
SubType Name 0 On/Off 1 Doorbell 2 Contact iii Blinds four X10 Siren v Smoke Detector vi Blinds Inverted 7 Dimmer viii Motion Sensor 9 Push On Button 10 Push button Off Button 11 Door Contact 12 Dusk Sensor 13 Blinds Pct 14 Venetian Blinds US 15 Venetian Blinds EU 16 Blinds Percent Inverted 17 Media Player eighteen Selector 19 Door Lock xx Door Lock Inverted
Rename hardware
/json.htm?type=command¶m=updatehardware&htype=<type>&proper name=<new proper noun>&enabled=<true or simulated>&idx=<hardware idx>
To get the required information from the hardware showtime practise
/json.htm?type=hardware
Rename device / sensor
/json.htm?type=setused&idx=<device ID>&proper noun=<new name>&used=truthful
Enable hardware
/json.htm?type=command¶m=updatehardware&htype=<type>&name=<proper name>&enabled=true&port=<port name>&idx=<hardware idx>&loglevel=<log level>
notation Utilise the consummate set of parms that you lot find when entering the enable command on the GUI considering if not completely entered it will destroy your hardware table. Exam first on a test organisation !!
Disable hardware
/json.htm?blazon=command¶m=updatehardware&htype=<type>&name=<proper name>&enabled=fake&idx=<hardware idx>
To get the required data from the hardware first practise
/json.htm?type=hardware
notation Use the consummate prepare of parms that you find when entering the disable command on the GUI considering if not completely entered information technology volition remove data from the parms. Exam on a examination system outset !!
Delete hardware
/json.htm?type=command¶m=deletehardware&idx=<hardware idx>
{ "status" : "OK" , "championship" : "DeleteHardware" } Delete a device or sensor
/json.htm?blazon=setused&used=false&idx=<device idx>
{ "status" : "OK" , "title" : "SetUsed" } Enable/Disable a device or sensor
/json.htm?blazon=control¶m=setdevused&idx=<device idx>&used=<true/fake>&name=<device name>
(device name is a optional parameter)
{ "status" : "OK" , "title" : "SetDeviceUsed" } Enable a disabled device or sensor
/json.htm?idx=<device idx>&name=<new proper name>&type=setused&used=true
or
/json.htm?idx=<device idx>&blazon=setused&used=true
{ "condition" : "OK" , "title" : "SetUsed" } Add together an On activeness and/or an Off activeness to a device or sensor
/json.htm?type=setused&used=true&idx=IDX&strparam1=base64Encoded(ON ACTION Cord)&strparam2=base64Encoded(OFF ACTION STRING)
{ "status" : "OK" , "title" : "SetUsed" } Transfer device
/json.htm?type=transferdevice&idx=IDX_1&newidx=IDX_2
Transfer sensor log of device with oldest lastUpdate value to device with virtually recent lastUpdate value. So not necessarily from IDX_1 to IDX_2 or the other way around. Source device is removed after transfer of logs.
{ "condition" : "OK" , "title" : "TransferDevice" } Update devices/sensors
Notation that when y'all utilise this ¶m=udevice selection with the additional option &parsetrigger=false, the device is updated without running the associated on/off- and script actions.
Good usage. Straight set device parameters via JSON.
Be conscientious when firing values to domoticz.db as there is a gamble to crash the database if parameters are wrong or missing. Beginning get to the devices tab and notice the device index (idx) of the device y'all want to modify
Generic update API's
Notation make sure stringparms must exist urlenecoded (eg. <space> %20, <Double quote> %27 etc..
alter Icon Not available for all device types
/json.htm?type=setused&used=truthful&name=<devicename>&description=<clarification>&idx=<idx>&switchtype=<switchType>&customimage=<iconNumber>
{ "status" : "OK" , "title" : "SetUsed" } change proper name
/json.htm?type=command¶m=renamedevice&name=<new devicename>&idx=<idx>
{ "status" : "OK" , "title" : "RenameDevice" } protection On / Off
/json.htm?type=setused&used=truthful&protected=<true/falseidx=<idx>
{ "status" : "OK" , "title" : "SetUsed" } update in domoticz just
does not parse the actual command to the hardware (similar MQTT)
with parsetrigger=false -->> No event is triggered either
/json.htm?blazon=command¶m=udevice&idx=<idx>&nvalue=<numeric value>&svalue=<string value>&parsetrigger=<false/truthful>
{ "status" : "OK" , "title" : "Update Device" } } Temperature
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP
- IDX = id of your device (This number can be plant in the devices tab in the column "IDX")
- TEMP = Temperature
{ "status" : "OK" , "championship" : "Update Device" } Humidity
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=HUM&svalue=HUM_STAT
The above sets the parameters for a Humidity device
- IDX = id of your device (This number tin can exist establish in the devices tab in the column "IDX")
- HUM = Humidity: 45%
- HUM_STAT = Humidity_status
Humidity_status can be one of:
- 0=Normal
- 1=Comfy
- 2=Dry out
- 3=Wet
{ "status" : "OK" , "title" : "Update Device" } Barometer
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=BAR;BAR_FOR
The above sets the parameters for a Barometer device from hardware type 'General'
- IDX = id of your device (This number can be found in the devices tab in the cavalcade "IDX")
- BAR = Barometric pressure
- BAR_FOR = Barometer forecast
Barometer forecast can be one of:
0 = Stable
i = Sunny
2 = Cloudy
3 = Unstable
4 = Thunderstorm
5 = Unknown
6 = Cloudy/Rain
Barometer forecast of other device types can be one of:
0 = Heavy Snow
ane = Snow
2 = Heavy Rain
3 = Rain
4 = Cloudy
5 = Some Clouds
6 = Sunny
7 = Unknown
8 = Unstable
9 = Stable
{ "status" : "OK" , "title" : "Update Device" } Temperature/humidity
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT
- IDX = id of your device (This number can exist establish in the devices tab in the column "IDX")
- TEMP = Temperature
- HUM = Humidity (0-100 %)
- HUM_STAT = Humidity condition
HUM_STAT can be 1 of:
- 0=Normal
- 1=Comfy
- two=Dry out
- 3=Wet
{ "status" : "OK" , "title" : "Update Device" } Temperature/humidity/barometer
/json.htm?type=control¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT;BAR;BAR_FOR
The higher up sets the parameters for a Temp+Humidity+Barometer device
- IDX = id of your device (This number can exist found in the devices tab in the column "IDX")
- TEMP = Temperature
- HUM = Humidity
- HUM_STAT = Humidity condition
- BAR = Barometric pressure
- BAR_FOR = Barometer forecast
HUM_STAT tin can exist ane of:
- 0=Normal
- one=Comfortable
- 2=Dry
- iii=Wet
Barometer forecast of device blazon "Full general" (Virtual) tin be one of:
0 = Stable
one = Sunny
two = Cloudy
3 = Unstable
four = Thunderstorm
5 = Unknown
6 = Cloudy/Pelting
Barometer forecast of other device types can be ane of:
0 = Heavy Snow
one = Snow
ii = Heavy Rain
three = Rain
4 = Cloudy
5 = Some Clouds
6 = Sunny
7 = Unknown
8 = Unstable
9 = Stable
{ "status" : "OK" , "championship" : "Update Device" } Temperature/barometer
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP;BAR;BAR_FOR;ALTITUDE
The above sets the parameters for a Temp+Humidity+Barometer device
- IDX = id of your device (This number tin be found in the devices tab in the column "IDX")
- TEMP = Temperature
- BAR = Barometric force per unit area
- BAR_FOR = Barometer forecast
- Altitude= Optional. Non used at the moment, can be 0
Barometer forecast tin be one of:
0 = Stable
1 = Sunny
2 = Cloudy
3 = Unstable
4 = Thunderstorm
5 = Unknown
6 = Cloudy/Rain
Barometer forecast of other device types tin can exist one of:
0 = Heavy Snowfall
1 = Snow
2 = Heavy Pelting
3 = Pelting
4 = Cloudy
5 = Some Clouds
half-dozen = Sunny
7 = Unknown
viii = Unstable
9 = Stable
{ "status" : "OK" , "title" : "Update Device" } Rain
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=RAINRATE;RAINCOUNTER
- IDX = id of your device (This number can be constitute in the devices tab in the column "IDX")
- RAINRATE = corporeality of rain in last hour in [mm x 100]
- RAINCOUNTER = continues counter of fallen Rain in [mm]
Soil Wet
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=MOISTURE
- IDX = id of your device (This number tin be establish in the devices tab in the column "IDX")
- MOISTURE = wet content in cb 0-200 where:
00 - 09 = saturated, ten - 19 = adequately wet, 20 - 59 = irrigation advice, sixty - 99 = irrigation, 100-200 = Dangerously dry,
Wind
/json.htm?type=control¶m=udevice&idx=IDX&nvalue=0&svalue=WB;WD;WS;WG;22;24
- IDX = id of your device (This number can be found in the devices tab in the column "IDX")
- WB = Wind bearing (0-359)
- WD = Wind direction (S, SW, NNW, etc.)
- WS = 10 * Wind speed [m/s]
- WG = x * Gust [m/s]
- 22 = Temperature
- 24 = Temperature Windchill
UV
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=UV;TEMP
- IDX = id of your device (This number tin be found in the devices tab in the column "IDX")
- UV = Bladder (instance: 2.1) with electric current UV reading.
- TEMP = temperature (only for UV subtype TFA (3), else specify 0)
Don't loose the ";0" at the end - without information technology database may corrupt.
If no temp is in use, specify 0 equally temperature
Counter
/json.htm?type=control¶m=udevice&idx=IDX&svalue=COUNTER
- IDX = id of your device (this number tin be found in the devices tab in the column "IDX")
- COUNTER = Integer of the overall total counter (Energy, Volume, Custom).
When in that location is a counter created, there is a possibility to change the units past clicking on "Modify" at the utility tab.
- Energy (reports kWh), requite COUNTER value in Wh, integer
- Energy Generated (reports kWh). give COUNTER value in Wh, integer
- Gas (reports mthree) , give COUNTER value in liter (1000 liter = 1 m³), integer
- Water (reports m3), give COUNTER value in liter (g liter = one yard³), integer
- Counter (no unit of measurement)
- Time (min?), seems to be obsolete, use Counter instead and employ the time units as desired (eg Sec, min, hrs)
The counter volition exist treated with the divider which is defined in the parameters in the application settings. For example if the counter is set to "Water" and the value is passed equally liters, the divider must prepare to 1000 (as the unit is m3). The device displays ii values:
- The status is the overall total book (or counter).
- The volume (or counter) of the twenty-four hours (in the top right corner).
The today's volume (or counter) is calculated from the total book (or counter).
Counter Incremental
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=one
volition increment the counter value past ane. To reset an incremental counter, set the svalue to a negative integer equal to the electric current total of the counter.
Electricity (instant and counter)
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=POWER;ENERGY
- IDX = id of your device (This number tin be constitute in the devices tab in the column "IDX")
- Ability = current power
- Free energy = total cumulative energy in Watt-hours (Wh)
(Energy Read type (use edit push button to change): Default: From Device. If the device is not able to ship the ENERGY counter values you choose "Free energy read: Computed". This will ignore ENERGY counter values and Domoticz volition calculate the Energy (kWh) internally based on the (previous/electric current) POWER (Watt) values. By design this is less accurate then using the ENERGY counter when using them "from Device".)
Domoticz will summate the today values based on the delta'southward in the total cumulative energy of today.
Managed counter
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=COUNTER;USAGE
- IDX = id of your device (This number tin can be found in the devices tab in the column "IDX")
- COUNTER = total cumulative counter energy (Wh, can be gear up to -1 if unknown or unused, in that case information technology won't show on dashboard or in logs)
- USAGE = energy usage in Watt-hours (Wh).
Managed counter will not transfer automatically every day information from device status to history log, it'due south up to an external script or plugin to insert data in history log database (useful to show non realtime consumption of energy provider that put energy information "in the cloud").
To insert information in history log:
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=COUNTER;USAGE;Appointment
- IDX = id of your device (This number tin can be plant in the devices tab in the cavalcade "IDX")
- COUNTER = total cumulative counter energy (Wh, can be fix to -1 if unknown or unused, in that case information technology won't show on dashboard or in logs)
- USAGE = energy usage in Watt-hours (Wh)
- Date = date with %Y-%m-%d format (for instance 2019-09-24) to put data in concluding week/calendar month/year history log, or "%Y-%chiliad-%d %H:%One thousand:%S" format (for instance 2019-10-03 14:00:00) to put data in final days history log
Electricity Electric current/Ampere 3 Phase
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=Ampere_1;=Ampere_2;=Ampere_3;
- IDX = id of your device (This number tin be found in the devices tab in the column "IDX")
- Ampere_1 = Ampere value Stage ane
- Ampere_2 = Ampere value Phase ii
- Ampere_3 = Ampere value Stage three
Electricity P1 smart meter
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD
- IDX = id of your device (This number can be found in the devices tab in the column "IDX")
- USAGE1= total cumulative energy usage meter tariff 1 in Wh.
- USAGE2= total cumulative energy usage meter tariff 2 in Wh.
- RETURN1= total cumulative energy return meter tariff 1 in Wh.
- RETURN2= total cumulative energy return meter tariff 2 in Wh.
- CONS= actual usage ability (Watt)
- PROD= actual return power (Watt)
USAGE and RETURN are full cumulative counters (they should just count upward).
For USAGE and Return supply the data in total Wh with no decimal indicate.
(So if your meter displays f.i. USAGE1= 523,66 KWh you need to send 523660)
Domoticz will calculate the today values based on the delta'south in the total cumulative energy of today.
Air quality
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=PPM
- IDX = id of your device (This number can be found in the devices tab in the column "IDX")
- PPM = CO2-concentration
Pressure level
/json.htm?type=control¶m=udevice&idx=IDX&nvalue=0&svalue=BAR
- IDX = id of your device (This number tin be plant in the devices tab in the column "IDX")
- BAR = Force per unit area in Bar
Create sensor under Hardware > Dummy > Create virtual sensor
Percentage
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=Per centum
- IDX = id of your device (this number can exist establish in the devices tab in the cavalcade "IDX")
- Pct = Percentage
Visibility
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=VISIBILITY
- IDX = id of your device (this number tin can be found in the devices tab in the column "IDX")
- VISIBILITY = in KM
Gas
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=USAGE
- USAGE= Gas usage in liter (1000 liter = ane one thousand³)
So if your gas meter shows f.i. 145,332 m³ yous should ship 145332.
The USAGE is the total usage in liters from start, non f.i. the daily usage.
Lux
/json.htm?type=command¶m=udevice&idx=IDX&svalue=VALUE
- IDX = device ID of Lux device
- VALUE = value of luminosity in Lux (INTEGER/FLOAT)
Voltage
/json.htm?blazon=control¶m=udevice&idx=IDX&nvalue=0&svalue=VOLTAGE
- IDX = device ID of Voltage device
- VALUE = value of voltage sensor in Volts
Create sensor under Hardware > Dummy > Create virtual sensor
Text sensor
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEXT
- IDX = id of your device (This number tin can be found in the devices tab in the cavalcade "IDX")
- TEXT = Text you desire to display
Alert sensor
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=LEVEL&svalue=TEXT
- IDX = id of your device (This number tin be found in the devices tab in the column "IDX")
- Level = (0=grey, i=light-green, ii=xanthous, 3=orange, iv=ruby)
- TEXT = Text you want to brandish
Distance sensor
/json.htm?blazon=command¶m=udevice&idx=IDX&nvalue=0&svalue=DISTANCE
- IDX = id of your device (This number can be found in the devices tab in the column "IDX")
- Distance = altitude in cm or inches, can be in decimals. For instance 12.half-dozen
Selector Switch
/json.htm?type=command¶m=switchlight&idx=IDX&switchcmd=Set up%20Level&level=LEVEL
- IDX = id of your device (This number tin be found in the devices tab in the column "IDX")
- LEVEL = level of your selector (This number tin can be establish in the edit selectors folio, in the cavalcade "Level", 0 = Off)
Custom Sensor
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=VALUE
- IDX = id of your device (This number tin can be found in the devices tab in the column "IDX")
- VALUE = Value (like 12.345)
Notation on counters
Usually, counters are updated daily to feed calendar week/month/year history log views. Starting version four.11774, if y'all desire to disable that behavior to control everything from an external script or a plugin (already the case for managed counter), you can set the "DisableLogAutoUpdate" device option to "truthful", for instance in a Python plugin:
Domoticz.Device(Name="MyCounter", Unit=one, Type=0xfa, Subtype=0x01, Options={"DisableLogAutoUpdate": "true").Create()
Starting version 4.11774, you can likewise directly insert data in in history log. Set the "AddDBLogEntry" device option to "true", for instance in a Python plugin:
Domoticz.Device(Name="MyCounter", Unit=ane, Blazon=0xfa, Subtype=0x01, Options={"AddDBLogEntry": "truthful").Create() With a json the parameter {"AddDBLogEntry" : "true"} should first exist URI encoded and then base64 encoded.
/json.htm?type=setused&idx=DEVICE_IDX&name=SENSORNAME&switchtype=SUBTYPE_VALUE&used=true&options=CODE
CODE=JTdCJTIyQWRkREJMb2dFbnRyeSUyMiUzQSslMjJ0cnVlJTIyJTdE ????
Then, depending on counters, you can insert values in history log. For most counters:
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=COUNTER;USAGE;Date
- IDX = id of your device (This number can be found in the devices tab in the cavalcade "IDX")
- COUNTER = total cumulative counter energy (Wh)
- USAGE = energy usage in Watt-hours (Wh)
- Date = date with %Y-%1000-%d format (for instance 2019-09-24) to put data in final week/month/year history log, or "%Y-%m-%d %H:%M:%S" format (for case 2019-x-03 14:00:00) to put data in last days history log
For multi meters (P1 Smart Meter, CM113, Electrisave and CM180i):
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD;DATE
- IDX = id of your device (This number tin be found in the devices tab in the column "IDX")
- USAGE1= energy usage meter tariff 1, This is an incrementing counter
- USAGE2= energy usage meter tariff 2, This is an incrementing counter
- RETURN1= free energy render meter tariff 1, This is an incrementing counter
- RETURN2= energy render meter tariff 2, This is an incrementing counter
- CONS= actual usage power (Watt)
- PROD= actual return power (Watt)
- Date = appointment with %Y-%grand-%d format (for instance 2019-09-24) to put information in last week/month/twelvemonth history log, or "%Y-%m-%d %H:%M:%South" format (for example 2019-10-03 14:00:00) to put data in terminal days history log
or
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD;COUNTER1;COUNTER2;COUNTER3;COUNTER4;Date
as previously, plus absolute counter values
Additional parameters (signal level & bombardment level)
In that location are two boosted parameters for the in a higher place commands, to specify the signal level (default 12) and the battery level (default 255)
battery level 255 = no battery device, else 0-100
example: &rssi=10&battery=89
Security
Become Password
to exist able to set the security status, the (encoded) countersign is required.
/json.htm?type=settings
{ "AcceptNewHardware" : 0 , "ActiveTimerPlan" : 2 , "AllowWidgetOrdering" : 1 , "AuthenticationMethod" : 1 , "BatterLowLevel" : 0 , "CM113DisplayType" : 0 , ..... "SecPassword" : "bfa2bea3x" , .... "WindUnit" : four , "cloudenabled" : true , "status" : "OK" , "title" : "settings" } get the value from key "SecPassword" ;for the purpose of this wiki we assume the value read is "bfa2bea3x"
Get security land
/json.htm?type=control¶m=getsecstatus
{ "secondelay" : 2 , "secstatus" : 1 , "condition" : "OK" , "championship" : "GetSecStatus" } where secstatus is
0 = Disarmed 1 = Arm Abode two = Arm Away three = Unknown
Prepare security state
/json.htm?type=command¶m=setsecstatus&secstatus=<status>&seccode=bfa2bea3x
{ "condition" : "OK" , "title" : "SetSecStatus" } Fume Detection
Actuate
/json.htm?blazon=command¶m=switchlight&idx=<IDX>&switchcmd=On
{ "status" : "OK" , "championship" : "SwitchLight" } Deactivate
/json.htm?blazon=command¶m=switchlight&idx=<IDX>&switchcmd=Off
{ "status" : "OK" , "championship" : "SwitchLight" } Reset
/json.htm?blazon=control¶m=resetsecuritystatus&idx=<IDX>&switchcmd=Off
{ "status" : "OK" , "title" : "ResetSecurityStatus" } /json.htm?blazon=control¶m=resetsecuritystatus&idx=3456&switchcmd=Normal
{ "status" : "OK" , "title" : "SwitchLight" } User variables
Add a new variable
- USERVARIABLENAME with the name of the variable
- USERVARIABLETYPE is a digit (0,i,2,3,iv) or a cord (Integer, Float, String, Date, Time)
0 = Integer, e.g. -1, one, 0, ii, x 1 = Float, east.g. -ane.1, 1.ii, three.one 2 = String 3 = Date in format DD/MM/YYYY 4 = Time in 24 hr format HH:MM
- USERVARIABLEVALUE with the value
All formats are checked by the api, when the variable does not lucifer the required format it is not stored.
/json.htm?type=command¶m=adduservariable&vname=USERVARIABLENAME&vtype=USERVARIABLETYPE&vvalue=USERVARIABLEVALUE
{ "status" : "OK" , "championship" : "AddUserVariable" } Update an existing variable
Remember to change:
- USERVARIABLENAME with the proper noun of your variable
- USERVARIABLETYPE according to the table from "Add a new variable"
- USERVARIABLEVALUE with the new value
Note: events will only exist triggered when the variabletype and variablename are not changed by the update command.
/json.htm?type=command¶m=updateuservariable&vname=USERVARIABLENAME&vtype=USERVARIABLETYPE&vvalue=USERVARIABLEVALUE
{ "status" : "OK" , "championship" : "UpdateUserVariable" } Listing all variables
/json.htm?blazon=command¶m=getuservariables
{ "result" : [ { "LastUpdate" : "2020-01-xiii 09:04:17" , "Name" : "setup-test" , "Type" : "2" , "Value" : "Hi" , "idx" : "1" }, { "LastUpdate" : "2020-02-17 xvi:48:03" , "Name" : "presence-test" , "Type" : "0" , "Value" : "one" , "idx" : "2" }, .... { "LastUpdate" : "2021-03-02 21:10:54" , "Name" : "UV_Night" , "Type" : "ii" , "Value" : "21:11" , "idx" : "44" } ], "status" : "OK" , "championship" : "GetUserVariables" } Listing one variable
/json.htm?type=command¶m=getuservariable&idx=IDX
- IDX = id of your variable (This number can exist constitute using the "List all variables" call above)
{ "consequence" : [ { "LastUpdate" : "2021-03-02 21:x:54" , "Proper noun" : "UV_Night" , "Blazon" : "ii" , "Value" : "21:11" , "idx" : "44" } ], "status" : "OK" , "title" : "GetUserVariable" } Delete a variable
- IDX = id of your variable (This number can exist found using the "List all variables" telephone call above)
/json.htm?type=command¶m=deleteuservariable&idx=IDX
{ "status" : "OK" , "title" : "DeleteUserVariable" } trigger dzVents script using customEvent dzVents iii.0.0
/json.htm?type=command¶m=customevent&effect=MyEvent&data=MyData
{ "condition" : "OK" , "title" : "Custom Result" } Room Plans
Listing all rooms
/json.htm?type=plans&club=name&used=true
{ "issue" : [ { "Devices" : 6 , "Name" : "Google Calendars" , "Order" : "ii" , "idx" : "2" }, { "Devices" : two , "Proper name" : "Private" , "Order" : "3" , "idx" : "3" }, { "Devices" : 1 , "Name" : "EVOHome" , "Lodge" : "four" , "idx" : "4" }, { "Devices" : 0 , "Proper name" : "testPlan" , "Society" : "5" , "idx" : "5" } ], "status" : "OK" , "title" : "Plans" } List all devices in a room
- IDX = id of your room
/json.htm?blazon=control¶m=getplandevices&idx=IDX
Evidence idx, proper name of the device like:
{ "result" : [ { "DevSceneRowID" : "492" , "Name" : "device proper name" , "devidx" : "492" , "idx" : "9" , "order" : "9" , "blazon" : 0 } ], "condition" : "OK" , "title" : "GetPlanDevices" } /json.htm?type=devices&program=IDX
prove details of the devices like
{ "ActTime" : 1569909986 , "AstrTwilightEnd" : "21:14" , "AstrTwilightStart" : "05:50" , "CivTwilightEnd" : "nineteen:54" , "CivTwilightStart" : "07:09" , "DayLength" : "11:39" , "NautTwilightEnd" : "20:34" , "NautTwilightStart" : "06:xxx" , "ServerTime" : "2019-10-01 08:06:26" , "SunAtSouth" : "13:32" , "Sunrise" : "07:42" , "Sunset" : "19:21" , "app_version" : "4.11337" , "result" : [ { "AddjMulti" : one , "AddjMulti2" : 1 , "AddjValue" : 0 , "AddjValue2" : 0 , "BatteryLevel" : 255 , "CustomImage" : 0 , "Information" : "19.5 C, (13.5 C), PermanentOverride" , "Description" : "" , "Favorite" : 1 , "HardwareID" : 30 , "HardwareName" : "Evohome" , "HardwareType" : "Evohome via Spider web API" , "HardwareTypeVal" : 75 , "HaveTimeout" : false , "ID" : "1168736" , "LastUpdate" : "2019-10-01 08:05:35" , "Proper noun" : "Device name" , "Notifications" : "false" , "PlanID" : "4" , "PlanIDs" : [ 4 ], "Protected" : imitation , "SetPoint" : 13.v , "ShowNotifications" : true , "SignalLevel" : 10 , "Status" : "PermanentOverride" , "SubType" : "Zone" , "Temp" : 19.5 , "Timers" : "faux" , "Type" : "Heating" , "TypeImg" : "override_mini" , "Unit" : 7 , "Used" : 1 , "XOffset" : "0" , "YOffset" : "0" , "idx" : "492" } ], "status" : "OK" , "title" : "Devices" } Timer Plans
Listing all Timerplans
/json.htm?type=command¶m=gettimerplans
{ "result" : [ { "Active" : simulated , "Name" : "Default" , "idx" : 0 }, { "Active" : true , "Name" : "Holiday" , "idx" : 1 }, { "Agile" : false , "Name" : "Mean solar day off (including weekend)" , "idx" : 2 } ], "status" : "OK" , "title" : "GetTimerPlans" } Add Timerplan
/json.htm?blazon=command¶m=addtimerplan&name=newTimerplan
{ "condition" : "OK" , "title" : "AddTimerPlan" } Change Timerplan name
/json.htm?type=command¶m=updatetimerplan&idx=iii&proper noun=newname
{ "status" : "OK" , "title" : "UpdateTimerPlan" } Duplicate Timerplan
This will re-create all existing timers from timerplan with idx 3 to a new plan
/json.htm?type=control¶m=duplicatetimerplan&idx=3&name=duplicatename
{ "status" : "OK" , "championship" : "DuplicateTimerPlan" } Make Timerplan active
This will make the timerplan with idx 2 the active one
/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=2
{ "status" : "OK" , "title" : "SetActiveTimerPlan" } History
Switch devices
/jso northward .h t thou? t ype=ligh tl og&idx=IDX Delete
/json.htm?blazon=control¶m=clearlightlog&idx=<idx>
Text devices
/json.htm?type=textlog&idx=IDX
Delete
/json.htm?type=command¶m=clearlightlog&idx=<idx>
Temperature
/json.htm?type=graph&sensor=temp&idx=IDX&range=mean solar day /json.htm?blazon=graph&sensor=temp&idx=IDX&range=calendar month /json.htm?type=graph&sensor=temp&idx=IDX&range=year /json.htm?type=graph&sensor=temp&idx=IDX&range=year&actyear=YYYY
Setpoint
See Temperature
Custom sensor
Totals by period:
/json.htm?type=graph&sensor=Percent&idx=IDX&range=twenty-four hour period
{{ "result" : [ { "d" : "2021-02-04 16:forty" , "v" : "308.6" }, { "d" : "2021-02-04 xvi:45" , "v" : "308.half dozen" }, ..... ], "status" : "OK" , "title" : "Graph Percentage day" } /json.htm?type=graph&sensor=Per centum&idx=IDX&range=month /json.htm?type=graph&sensor=Percentage&idx=IDX&range=yr /json.htm?type=graph&sensor=Percentage&idx=IDX&range=year&actyear=YYYY
{ "result" : [ { "d" : "2021-01-xviii" , "v_avg" : "308.half dozen" , "v_max" : "309.6" , "v_min" : "307.6" }, { "d" : "2021-01-xix" , "v_avg" : "308.6" , "v_max" : "310.6" , "v_min" : "306.vi" }, { "d" : "2021-01-21" , "v_avg" : "308.6" , "v_max" : "310.6" , "v_min" : "306.vi" }, ... { "d" : "2021-02-18" , "v_avg" : "308.half-dozen" , "v_max" : "310.vi" , "v_min" : "306.6" } ], "status" : "OK" , "title" : "Graph Percent <...>" } Free energy, Gas, H2o
Instantaneous consumption:
/json.htm?type=graph&sensor=counter&idx=IDX&range=day&method=i
Totals by flow:
/json.htm?type=graph&sensor=counter&idx=IDX&range=day /json.htm?type=graph&sensor=counter&idx=IDX&range=calendar month /json.htm?blazon=graph&sensor=counter&idx=IDX&range=year /json.htm?type=graph&sensor=counter&idx=IDX&range=yr&actyear=YYYY
Deleting History log entries
delete a single data point or day
/json.htm?type=command¶m=deletedatapoint&idx=IDX&date=Appointment
- IDX = id of your device (This number can be constitute in the devices tab in the column "IDX")
- DATE = date in %Y-%1000-%d format (for example 2021-02-26) volition delete history data of that detail solar day (one entry from long term history and max 120 entries from short term history log)
- Engagement = date in "%Y-%yard-%d%20%H:%Chiliad:%S" format (for instance 2019-ten-03%2014:00:00) will delete history data of that particular time (one entry from short term history log)
{ "status" : "OK" , "title" : "deletedatapoint" } delete a date range of information points
/json.htm?type=command¶m=deletedaterange&idx=IDX&fromdate=FROMDATE&todate=TODATE V2020.2 build >= 13027
- IDX = id of your device (This number can be constitute in the devices tab in the column "IDX")
- FROMDATE = engagement in %Y-%m-%d or appointment in "%Y-%m-%d%20%H:%M:%Southward"format (for instance 2021-02-26 / 2019-10-03%2014:00:00) will delete history data (from brusque and long history tables) starting with that mean solar day / fourth dimension
- TODATE = date in %Y-%m-%d or appointment in "%Y-%m-%d%xx%H:%M:%S"format (for example 2021-02-26 / 2019-10-03%2014:00:00) will delete history data (from brusk and long history tables) ending with that day / time
{ "status" : "OK" , "title" : "deletedaterange" } Device Timer Schedules
Get all schedules (timers)
/json.htm?type=schedules
{ "result" : [ { "Active" : "true" , "Date" : "" , "Days" : 128 , "DevName" : "Porch Light" , "DeviceRowID" : 52 , "Hue" : 0 , "IsThermostat" : "false" , "Level" : 100 , "MDay" : 0 , "Month" : 0 , "Occurence" : 0 , "Randomness" : "fake" , "ScheduleDate" : "2016-04-01 20:33:00" , "Time" : "00:20" , "TimerCmd" : 0 , "TimerID" : ix , "TimerType" : 4 , "TimerTypeStr" : "Later on Sunset" , "Type" : "Device" }, Get all schedules(timers) for all Devices
/json.htm?type=schedules&filter=device
{ "effect" : [ { "Active" : "true" , "Colour" : "" , "Date" : "" , "Days" : 128 , "DevName" : "coffeeSwitch" , "DeviceRowID" : 1014 , "IsThermostat" : "faux" , "Level" : 100 , "MDay" : 0 , "Month" : 0 , "Occurence" : 0 , "Randomness" : "false" , "ScheduleDate" : "2021-03-xi 06:01:00" , "Time" : "06:01" , "TimerCmd" : 0 , "TimerID" : 62 , "TimerType" : 2 , "TimerTypeStr" : "On Time" , "Blazon" : "Device" }, { "Active" : "true" , "Colour" : "" , "Date" : "" , "TimerType" : 2 , "TimerTypeStr" : "On Time" , "Type" : "Device" } ], "status" : "OK" , "title" : "Schedules" } Get all schedules(timers) for i Device
/json.htm?idx=timerID&type=timers
Type returns
- 0: Before Sunrise
- i: After Sunrise
- 2: On Fourth dimension
- iii: Earlier Dusk
- 4: Later Sunset
- 5: Fixed Appointment/Time
- six: Odd Solar day Numbers
- 7: Even Day Numbers
- 8: Odd Week Numbers
- 9: Fifty-fifty Week Numbers
- 10: Monthly
- 11: Monthly (Weekday)
- 12: Yearly
- 13: Yearly (Weekday)
- 14: Before Sun at Southward
- 15: Subsequently Sunday at Southward
- sixteen: Before Civil Twilight Showtime
- 17: After Civil Twilight Start
- 18: Before Civil Twilight Cease
- 19: After Civil Twilight End
- xx: Before Nautical Twilight Start
- 21: Afterward Nautical Twilight Commencement
- 22: Before Nautical Twilight Stop
- 23: After Nautical Twilight End
- 24: Before Astronomical Twilight Start
- 25: After Astronomical Twilight Start
- 26: Before Astronomical Twilight Terminate
- 27: After Astronomical Twilight Stop
{ "event" : [ { "Active" : "truthful" , "Cmd" : 0 , "Colour" : "" , "Engagement" : "" , "Days" : 128 , "Level" : 100 , "MDay" : 0 , "Calendar month" : 0 , "Occurence" : 0 , "Randomness" : "imitation" , "Time" : "08:thirty" , "Type" : 23 , "idx" : "45" } ], "status" : "OK" , "title" : "Timers" } Get all schedules(timers) for all Scenes
/json.htm?type=schedules&filter=scene
{ "result" : [ { "Agile" : "true" , "Color" : "" , "Date" : "" , "Days" : 128 , "DevName" : "Lights" , "DeviceRowID" : half-dozen , "IsThermostat" : "false" , "Level" : 100 , "MDay" : 0 , "Month" : 0 , "Occurence" : 0 , "Randomness" : "simulated" , "ScheduleDate" : "2021-03-12 07:01:00" , "Fourth dimension" : "00:03" , "TimerCmd" : 1 , "TimerID" : 4 , "TimerType" : 0 , "TimerTypeStr" : "Before Sunrise" , "Blazon" : "Scene" }, { "Agile" : "true" , "Color" : "" , "Date" : "" , "Days" : 128 , "DevName" : "Garden lights" , "DeviceRowID" : 6 , "IsThermostat" : "fake" , "Level" : 100 , "MDay" : 0 , "Month" : 0 , "Occurence" : 0 , "Randomness" : "false" , "ScheduleDate" : "2021-03-12 09:00:00" , "Time" : "09:00" , "TimerCmd" : 1 , "TimerID" : 6 , "TimerType" : 2 , "TimerTypeStr" : "On Fourth dimension" , "Blazon" : "Scene" }, { "Agile" : "true" , "Color" : "" , "Date" : "" , "Days" : 128 , "DevName" : "Frontdoor" , "DeviceRowID" : 5 , "IsThermostat" : "false" , "Level" : 100 , "MDay" : 0 , "Month" : 0 , "Occurence" : 0 , "Randomness" : "false" , "ScheduleDate" : "2021-03-12 01:thirty:00" , "Fourth dimension" : "01:30" , "TimerCmd" : 0 , "TimerID" : two , "TimerType" : two , "TimerTypeStr" : "On Time" , "Type" : "Scene" } ], "status" : "OK" , "title" : "Schedules" } Become all schedules(timers) for one Scene
/json.htm?idx=sceneID&blazon=scenetimers
{ "event" : [{ "Active" : "true" , "Cmd" : 0 , "Appointment" : "" , "Days" : 128 , "Level" : 100 , "MDay" : 0 , "Month" : 0 , "Occurence" : 0 , "Randomness" : "false" , "Time" : "01:30" , "Type" : 2 , "idx" : "2" } ], "status" : "OK" , "title" : "SceneTimers" } Get all schedules(timers) for all Thermostats
/json.htm?type=schedules&filter=thermostat
{ "status" : "OK" , "title" : "Schedules" } Get all schedules(timers) for one Thermostat
/json.htm?idx=timerID&blazon=setpointtimers
{ "status" : "OK" , "championship" : "SetpointTimers" } Enable specific schedule(timer) for Devices
/json.htm?type=command¶m=enabletimer&idx=timerID
{ "status" : "OK" , "title" : "EnableTimer" } Disable specific schedule(timer) for Devices
/json.htm?blazon=command¶m=disabletimer&idx=timerID
{ "status" : "OK" , "title" : "DisableTimer" } Delete a specific schedule(timer) for Devices
/json.htm?type=command¶m=deletetimer&idx=timerID
{ "condition" : "OK" , "championship" : "DeleteTimer" } Enable specific schedule(timer) for Thermostats
/json.htm?type=command¶m=enablesetpointtimer&idx=timerID
{ "condition" : "OK" , "championship" : "EnableSetpointTimer" } Disable specific schedule(timer) for Thermostats
/json.htm?type=command¶m=disablesetpointtimer&idx=timerID
{ "status" : "OK" , "title" : "DisableSetpointTimer" } Delete a specific schedule(timer) for Thermostats
/json.htm?type=control¶m=deletesetpointtimer&idx=timerID
{ "status" : "OK" , "championship" : "DeleteSetpointTimer" } Update parameters for a specific schedule(timer) for Devices
/json.htm?type=command¶m=updatetimer&idx=timerID&active=true&timertype=iii&60 minutes=0&min=xx&randomness=true&control=0&days=12345</source>
- idx = timerID
- active = truthful/false
- timertype - see Get all schedules(timers) for one Device for timerTypeDefinition
- hour = hour
- min = minute
- randomness = truthful/imitation
- command = On=0 / Off=i (inverted logic)
- days = 1=Mon, 2=Tue, three=Wed, four=Thurs, five=Friday, 6=Sat, seven=Sun
Create a new schedule(timer) for an existing device
/json.htm?blazon=command¶m=addtimer&idx=DeviceRowID&active=true&timertype=2&hr=0&min=twenty&randomness=fake&command=0&days=1234567
{ "condition" : "OK" , "title" : "AddTimer" } - idx = DeviceRowID = index of your device (other commands utilise a timerID every bit idx only here we use DeviceRowID).
- active = true/false
- timertype - see Get all schedules(timers) for 1 Device for timerTypeDefinition
- 60 minutes = hour
- min = minute
- randomness = true/false
- command = On=0 / Off=1 (inverted logic)
- days = 1=Mon, two=Tue, iii=Wed, 4=Thurs, five=Fri, 6=Sat, 7=Lord's day
Clear all schedules(timers) for a particular device
/json.htm?blazon=command¶m=cleartimers&idx=DeviceRowID
{ "status" : "OK" , "title" : "ClearTimer" } - idx = DeviceRowID = alphabetize of your device (other commands utilise a timerID every bit idx but here nosotros use DeviceRowID).
Enable specific schedule(timer) for Scenes/Groups
/json.htm?type=command¶m=enablescenetimer&idx=sceneID
{ "status" : "OK" , "championship" : "EnableSceneTimer" } Disable specific schedule(timer) for Scenes/Groups
/json.htm?type=control¶m=disablescenetimer&idx=sceneID
{ "status" : "OK" , "championship" : "DisableSceneTimer" } Delete a specific schedule(timer) for Scenes/Groups
/json.htm?type=control¶m=deletescenetimer&idx=sceneID
{ "status" : "OK" , "championship" : "DeleteSceneTimer" } Notifications
Become all notification types
/json.htm?type=notifications
{ "notifiers" : [{ "description" : "browser" , "proper noun" : "browser" }, { "description" : "clickatell" , "name" : "clickatell" }, { "description" : "electronic mail" , "name" : "email" }, { "description" : "fcm" , "name" : "fcm" }, { "clarification" : "http" , "name" : "http" }, { "description" : "kodi" , "name" : "kodi" }, { "description" : "lms" , "proper name" : "lms" }, { "description" : "prowl" , "name" : "prowl" }, { "clarification" : "pushalot" , "proper noun" : "pushalot" }, { "description" : "pushbullet" , "name" : "pushbullet" }, { "description" : "pushover" , "name" : "pushover" }, { "clarification" : "pushsafer" , "name" : "pushsafer" }, { "description" : "telegram" , "name" : "telegram" } ], "status" : "OK" , "title" : "Notifications" } Get device notifications
/json.htm?idx=<deviceIDX>¶m=getnotificationtypes&type=command
{ "outcome" : [ { "ptag" : "South" , "text" : "Switch On" , "val" : seven } ], "status" : "OK" , "title" : "GetNotificationTypes" } /json.htm?idx=<deviceIDX>&blazon=notifications
{ "notifiers" : [{ "description" : "browser" , "name" : "browser" }, { "description" : "clickatell" , "proper name" : "clickatell" }, { "description" : "electronic mail" , "name" : "email" }, { "description" : "fcm" , "proper name" : "fcm" }, { "description" : "http" , "name" : "http" }, { "description" : "kodi" , "name" : "kodi" }, { "description" : "lms" , "name" : "lms" }, { "description" : "prowl" , "name" : "prowl" }, { "description" : "pushalot" , "proper name" : "pushalot" }, { "description" : "pushbullet" , "proper name" : "pushbullet" }, { "description" : "pushover" , "proper noun" : "pushover" }, { "description" : "pushsafer" , "name" : "pushsafer" }, { "description" : "telegram" , "name" : "telegram" } ], "upshot" : [{ "ActiveSystems" : "clickatell;e-mail;fcm;http;kodi;lms;prowl;pushalot;pushbullet;pushover;pushsafer;telegram" , "CustomMessage" : "exam" , "Params" : "Southward" , "Priority" : 0 , "SendAlways" : false , "idx" : three } ], "status" : "OK" , "title" : "Notifications" } Add device notification
/json.htm?idx=<deviceIDX>¶m=addnotification&tmsg=test&tpriority=0&tsendalways=true&tsystems=fcm;http&ttype=7&tvalue=0&twhen=0&type=command
{ "condition" : "OK" , "title" : "AddNotification" } Update device notifications
/json.htm?devidx=<DeviceID>&idx=<notificationID>¶m=updatenotification&tmsg=<msgText>&tpriority=<pri>&tsendalways=<true/false>&tsystems=<listing of notification subsystems>&ttype=<notificationType>&tvalue=0&twhen=0&type=control
{ "status" : "OK" , "championship" : "UpdateNotification" } Delete device notification
json.htm?idx=<notificationID>¶m=deletenotification&type=command
{ "status" : "OK" , "title" : "DeleteNotification" } Delete all device notifications
/json.htm?idx=<deviceID>¶m=clearnotifications&type=command
{ "status" : "OK" , "title" : "ClearNotification" } LMS and Kodi (Media Players)
While both Logitech Media Server and Kodi can be controlled by JSON RPC commands sent directly to the URL of the LMS server or Kodi instance, information technology can be useful to use Domoticz as a tunnel/proxy to send a number of widely-used commands considering you may have an external port already open for Domoticz and considering Domoticz also supports HTTPS.
LMS
/jso n .h t m? t ype=comma n d¶m=lmsmediacomma north d&idx= nnn &air conditioning t io n =ACTION where Activity can be: Left, Right, Upwardly, Downwardly, Favorites, Browse, NowPlaying, Shuffle, Repeat, Play, Pause, Stop, Rewind, Forwards, Mute, VolumeUp, VolumeDown, PowerOn and PowerOff.
Kodi
/jso north .h t 1000? t ype=comma n d¶m=kodimediacomma n d&idx= nnn &ac t io n =Action where ACTION can be: PlayPause, Stop, FastForward, BigStepForward, Rewind, BigStepBack, ShowSubtitles, FullScreen, VolumeUp, VolumeDown, ChannelUp, ChannelDown, Channels Dwelling, Back, ContextMenu, Info, Select, Down, Correct, Up, Left
Evohome
These commands piece of work regardless of which of the 3 implementation-modes for Evohome you have called for your organisation (WebAPI, USB device, Scripting). Some of them will likewise work for eastward.g. the Honeywell Round WiFi thermostat.
Updating the evohome controller way
/jso n .h t thousand? t ype=comma n d¶m=swi t chmodal&idx=<idx>&s tatus =<s tatus >&ac t io due north =<ac t io northward >&ooc=<ooc> - <idx> id number of the evohome controller device in Domoticz
- <condition> Car, AutoWithReset, AutoWithEco, Abroad, DayOff, Custom, HeatingOff
- <activity> (1 = run on activeness script, 0 = disable)
- <ooc> (1 = only trigger the event & log on change, 0 = always trigger & log)
Specify an until date
/jso northward .h t thou? t ype=comma north d¶m=swi t chmodal&idx=<idx>&s tatus =<southward tatus >&ac t io n =<ac t io northward >&ooc=<ooc>&u nt il=<u nt il> - every bit above
- <until> ISO date fourth dimension to run until. Format example 2018-09-15T15:53:00 or 2018-09-15T15:53:00+01:00 with timezone.
Note: well-nigh controller modes practice not back up the fourth dimension part of the ISO information and will only human action upon the date portion - this volition crave at to the lowest degree the side by side day to exist reflected in the appointment number to successfully trigger an update.
Updating a zone setpoint
/jso north .h t 1000? t ype=se tuse d&idx=<idx>&se t poi nt =<se t poi nt >&mode=<mode>&used= true - <idx> id number of the relevant evohome zone device in Domoticz
- <setpoint> set indicate in degrees (will be ignored for Automobile)
- <mode> Auto, TemporaryOverride, PermanentOverride, FollowSchedule
- used must be true
Specifying a date/time for zone TemporaryOverride
/jso n .h t m? t ype=se tuse d&idx=<idx>&se t poi nt =<se t poi nt >&mode=TemporaryOverride&u nt il=<u nt il>&used= true - as above
- <until> ISO appointment time for the set bespeak override. Format example 2018-09-15T15:53:00 or 2018-09-15T15:53:00+01:00 with timezone.
In this case, any combination of a engagement portion and a time portion that are in the future volition encounter with success.
Turning HotWater ON/OFF
/jso n .h t m? t ype=se tuse d&idx=<idx>&se t poi nt =<se t poi nt >&s tate =<southward tate >&mode=<manner>&used= true - <idx> id number of the evohome DHW temp device in Domoticz
- <setpoint> set point in degrees (volition be ignored)
- <state> On, Off
- <mode> Auto, TemporaryOverride, PermanentOverride, FollowSchedule
- used must be true
Configuring zwave devices
Listing zwave node parameters
/jso north .h t m? t ype=ope n zwave n odes&idx=co ntr olleridx - controlleridx = the idx of your OpenZWave USB controller device, equally listed nether the 'Setup --> Hardware' tab.
Example output:
{ "NodesQueried" : truthful , "ownNodeId" : 1 , "result" : [ { "Description" : "Neo CoolCam Door/Window Detector" , "HaveUserCodes" : faux , "HomeID" : 3554707869 , "IsPlus" : truthful , "LastUpdate" : "2018-08-04 20:09:02" , "Manufacturer_id" : "0x0258" , "Manufacturer_name" : "Neo CoolCam" , "Name" : "Garage DOor" , "NodeID" : 40 , "PollEnabled" : "false" , "Product_id" : "0x1082" , "Product_name" : "Door/Window Detector" , "Product_type" : "0x0003" , "State" : "Sleeping" , "Version" : 4 , "config" : [ { "LastUpdate" : "2018-08-01 09:06:45" , "help" : "This configuration parameter that can be used to adjust the amount of delay before the OFF command is transmitted. This parameter tin can be configured with the value of 0 through 65535, where 0 means ship OFF command immediately and 65535 ways 65535 seconds of filibuster." , "index" : ane , "label" : "Configuring the OFF Filibuster" , "type" : "short" , "units" : "2nd" , "value" : "0" }, { "LastUpdate" : "2018-08-01 09:06:45" , "help" : "Bones Fix Command will be sent where contains a value when the door/window is opened or closed, the receiver will have it for consideration; for instance, if a lamp module is received the Bones Set Command of which value is decisive as to how bright of dim level of lamp module shall be." , "index" : 2 , "label" : "Basic Set Level" , "type" : "byte" , "units" : "" , "value" : "255" }, { "LastUpdate" : "2018-08-03 07:55:52" , "help" : "" , "index" : 2000 , "label" : "Wake-upwardly Interval" , "type" : "int" , "units" : "Seconds" , "value" : "43200" } ], "idx" : "11" }, { "Clarification" : "FIBARO System FGWPE/F Wall Plug" , "HaveUserCodes" : faux , "HomeID" : 3554707869 , "IsPlus" : false , "LastUpdate" : "2018-08-05 12:12:24" , "Manufacturer_id" : "0x010f" , "Manufacturer_name" : "FIBARO System" , "Name" : "Studio" , "NodeID" : five , . . . Note the node_idx towards the end of each device's entry (the "idx": "eleven" in the example above for the Neo CoolCam Door/Window Detector). Yous don't encounter this node_idx in the regular devices tab for Domoticz, but it is the idx you'll demand when changing a parameter through JSON (next section).
Getting the battery levels
/jso n .h t m? t ype=comma n d¶m=zwavege t ba tter ylevels&idx=co ntr olleridx - controlleridx = the idx of your OpenZWave USB controller device, as listed under the 'Setup --> Hardware' tab.
Example output:
{ "result" : [ { "battery" : 255 , "nodeID" : 17 , "nodeName" : "Designlamp bij Television" }, { "battery" : 255 , "nodeID" : 19 , "nodeName" : "Lichtknopje voorkamer" }, { "battery" : 100 , "nodeID" : 33 , "nodeName" : "Rookmelder" } ], "status" : "OK" , "title" : "GetBatteryLevels" } Note: a Battery level of 255 indicates either a non bombardment powered device, or a battery powered device which has not however transport a battery measurement to OpenZWave yet.
Changing a zwave device parameter
/jso n .h t m? t ype=comma north d¶m=applyzwave north odeco nf ig&idx= north ode_idx&valuelis t =plis t - node_idx = the value found past searching through the output of openzwavenodes for the node in question (see higher up)
- plist = the (partially) URI encoded and BASE64 encoded parameter list
The plist entries first with an unencoded decimal item number preceded by and followed by an underscore (e.yard. _7_), followed by the correctly-encoded cord. You tin can bank check out the encodings at the following links: base64decode and at urlencode. In Base64, 'Enable' is written every bit 'RW5hYmxl', so it looks odd simply information technology'south easy once yous grasp it.
For case, if you are configuring a NEO Coolcam Siren through JSON,
/jso n .h t m? t ype=comma n d¶m=applyzwave n odeco nf ig&idx= 10 &valuelis t = 7 _QWxhcm 0 gbXVzaWM% 3 D would change parameter seven (Configure Default Siren On Mode) to 'Alarm music', while
/jso n .h t m? t ype=comma due north d¶m=applyzwave north odeco nf ig&idx= 10 &valuelis t = vii _RG 9 vciBiZWxsIG 11 c two lj% 3 D would change it to 'Door bell music' (considering 'RG9vciBiZWxsIG11c2lj' is the result of Base64 encoding 'Door bell music'). Annotation: Any '%3D' and such in the plist are the upshot of URI encoding an '=' or other non-alphanumeric character.
The easiest way to larn near this is to change a zwave device parameter manually using your browser while you have programmer tools enabled (hit 'ctrl-shift-i' in Chrome). Look under the network tab at the JSON sent back past the browser to Domoticz when yous click on 'Apply Configuration for This Device'.
/jso due north .h t m? t ype=comma north d¶m=applyzwave due north odeco nf ig&idx= x &valuelis t = 3 _MjU 1 _ one _SGl na A% 3 D% 3 D_ two _MSB ta W 51 dGU% three D_ four _TG 93 _ five _MTA% 3 D_ 6 _MQ% 3 D% 3 D_ seven _QWxhcm 0 gbXVzaWM% 3 D_ 8 _RW 5 hYmxl_ 9 _RGlzYWJsZQ% three D% 3 D_ The browser will actually send the full parameter list to Domoticz, including the unchanged values of any parameters you lot didn't modify. If you lot modify ane of them, nonetheless, you'll see that edit reflected in the Base64-encoded JSON cord.
Language-specific JSON examples
The post-obit tiny code snippets demonstrate the syntax for using JSON with Domoticz from some popular programming languages.
Bash
#!/bin/bash whorl -s 'http://192.168.178.12:8080/json.htm?type=devices&rid=104' | jq .result[ 0 ].Temp | sed 's/\"//g' | awk '{ impress $1 }' PHP
#!/usr/bin/php <?php $json_string = file_get_contents ( "http://192.168.178.12:8080/json.htm?type=devices&rid=110" ); $parsed_json = json_decode ( $json_string , truthful ); $test_link = "/domicile/pi/output.txt" ; $test_data = fopen ( $test_link , "w+" ); fwrite ( $test_data , print_R ( $parsed_json , TRUE )); fclose ( $test_data ); ?> Python
#!/usr/bin/python import urllib import urllib2 import requests ... url = 'http://192.168.178.12:8080/json.htm?type=control¶m=udevice&nvalue=0&idx=' + idx + '&svalue=' + sval try : asking = urllib2 . Request ( url ) response = urllib2 . urlopen ( request ) except urllib2 . HTTPError , e : print e . lawmaking ; time . sleep ( 60 ) except urllib2 . URLError , e : print e . args ; time . sleep ( threescore ) Perl
#!/usr/bin/perl use LWP::UserAgent ; use JSON::XS ; $url { domo } => 'http://192.168.178.12:8080' ; $idx = 301 ; $ua = LWP::UserAgent -> new ; $ua -> timeout ( 5 ); $recollect = $ua -> go ( $url { domo } . '/json.htm?blazon=devices&rid=' . $idx ); $res = $call back -> decoded_content ; if ( $call back -> is_success ) { $jres = JSON::XS -> new -> allow_nonref -> decode ( $res ) } else { warn $retrieve -> status_line }; $country = $$jres { issue }[ 0 ] -> { Status }; # 'On', 'Off', 'Open', 'Closed', etc print "The switch state for idx $idx is currently '$state'\due north" ; collinsstentartudge.blogspot.com
Source: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s
0 Response to "Urllib2 Read Only a Certain Amount of Text"
Post a Comment