pysmartthings
pysmartthings copied to clipboard
[Feature Request] Device Components
I'd like to be able to manipulate/read the individual device components exposed via the API if possible in Home Assistant. ie: toggle the icemaker, adjust the freezer/fridge setpoint, monitor the contact sensors separately.
If there's anything I can do to assist please let me know.
Example /v1/devices/{deviceID}/status:
{
"components": {
"icemaker": {
"custom.dthVersion": {
"versionNumber": {
"value": 19061701,
"timestamp": "2020-01-19T19:04:16.085+0000"
}
},
"switch": {
"switch": {
"value": "on",
"timestamp": "2020-03-23T22:18:53.534+0000"
}
}
},
"cooler": {
"custom.fridgeMode": {
"fridgeModeValue": {
"value": null,
"timestamp": "2020-06-08T16:43:51.174+0000"
},
"fridgeMode": {
"value": null,
"timestamp": "2020-06-07T03:10:59.253+0000"
}
},
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2020-10-09T01:46:29.366+0000"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [
"custom.fridgeMode"
],
"timestamp": "2020-01-19T18:58:40.057+0000"
}
},
"temperatureMeasurement": {
"temperature": {
"value": 37,
"unit": "F",
"timestamp": "2020-09-10T01:40:52.084+0000"
}
},
"sensor": {},
"custom.dthVersion": {
"versionNumber": {
"value": 19061701,
"timestamp": "2020-01-19T19:04:16.138+0000"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpoint": {
"value": 37,
"unit": "F",
"timestamp": "2020-09-10T01:40:52.450+0000"
}
}
},
"freezer": {
"custom.fridgeMode": {
"fridgeModeValue": {
"value": null,
"timestamp": "2020-06-07T02:50:56.927+0000"
},
"fridgeMode": {
"value": null,
"timestamp": "2020-06-07T02:16:12.076+0000"
}
},
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2020-10-09T01:40:48.072+0000"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [
"custom.fridgeMode"
],
"timestamp": "2020-01-19T18:58:40.049+0000"
}
},
"temperatureMeasurement": {
"temperature": {
"value": 0,
"unit": "F",
"timestamp": "2020-09-10T01:40:52.051+0000"
}
},
"sensor": {},
"custom.dthVersion": {
"versionNumber": {
"value": 19061701,
"timestamp": "2020-01-19T19:04:16.157+0000"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpoint": {
"value": 0,
"unit": "F",
"timestamp": "2020-09-10T01:40:52.689+0000"
}
}
},
"cvroom": {
"custom.fridgeMode": {
"fridgeModeValue": {
"value": null,
"timestamp": "2020-06-03T00:49:53.835+0000"
},
"fridgeMode": {
"value": "CV_FDR_DELI",
"timestamp": "2020-05-26T05:21:29.579+0000"
}
},
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2020-10-09T01:40:05.514+0000"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [
"temperatureMeasurement",
"thermostatCoolingSetpoint"
],
"timestamp": "2020-01-19T18:58:40.067+0000"
}
},
"temperatureMeasurement": {
"temperature": {
"value": null,
"timestamp": "2020-06-02T23:30:52.792+0000"
}
},
"sensor": {},
"custom.dthVersion": {
"versionNumber": {
"value": 19061701,
"timestamp": "2020-01-19T19:04:16.182+0000"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpoint": {
"value": null,
"timestamp": "2020-06-02T23:21:21.353+0000"
}
}
},
"main": {
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2020-10-09T01:46:29.304+0000"
}
},
"powerConsumptionReport": {
"powerConsumption": {
"value": null,
"timestamp": "2020-06-07T02:08:23.783+0000"
}
},
"refresh": {},
"filterStatus": {
"filterStatus": {
"value": "normal",
"timestamp": "2020-07-11T21:15:14.059+0000"
}
},
"custom.dthVersion": {
"versionNumber": {
"value": 20081001,
"timestamp": "2020-09-09T23:33:30.223+0000"
}
},
"execute": {
"data": {
"value": {
"payload": {
"if": [
"oic.if.s"
],
"rt": [
"x.com.samsung.da.rm.wifi"
],
"x.com.samsung.rm.rssi": [
-47
]
}
},
"data": {},
"timestamp": "2020-10-09T02:37:45.373+0000"
}
},
"custom.error": {
"error": {
"value": null,
"timestamp": "2020-06-07T02:03:05.577+0000"
}
},
"ocf": {
"st": {
"value": "2020-09-05T09:10:13Z",
"timestamp": "2020-09-09T23:34:23.794+0000"
},
"mndt": {
"value": "",
"timestamp": "2020-01-19T18:58:37.233+0000"
},
"mnfv": {
"value": "PRODUCT",
"timestamp": "2020-05-26T05:19:45.440+0000"
},
"mnhw": {
"value": "",
"timestamp": "2020-01-19T18:58:37.354+0000"
},
"di": {
"value": "7d3feb98-8a36-4351-c362-5e21ad3a78dd",
"timestamp": "2020-01-19T18:58:37.158+0000"
},
"mnsl": {
"value": "",
"timestamp": "2020-01-19T19:04:16.101+0000"
},
"dmv": {
"value": "res.1.1.0,sh.1.1.0",
"timestamp": "2020-01-19T18:58:37.175+0000"
},
"n": {
"value": "[refrigerator] Samsung (LCD)",
"timestamp": "2020-01-19T18:58:37.166+0000"
},
"mnmo": {
"value": "20K_REF_LCD_FHUB5.0|00113141|0002034e051324200103000000000000",
"timestamp": "2020-05-26T05:19:45.273+0000"
},
"vid": {
"value": "DA-REF-NORMAL-000001",
"timestamp": "2020-01-19T18:58:37.331+0000"
},
"mnmn": {
"value": "Samsung Electronics",
"timestamp": "2020-01-19T18:58:37.262+0000"
},
"mnml": {
"value": "",
"timestamp": "2020-01-19T18:58:37.300+0000"
},
"mnpv": {
"value": "4.0",
"timestamp": "2020-05-26T05:19:45.357+0000"
},
"mnos": {
"value": "Tizen",
"timestamp": "2020-01-19T18:58:37.286+0000"
},
"pi": {
"value": "7d3feb98-8a36-4351-c362-5e21ad3a78dd",
"timestamp": "2020-01-19T18:58:37.342+0000"
},
"icv": {
"value": "core.1.1.0",
"timestamp": "2020-01-19T18:58:37.146+0000"
}
},
"refrigeration": {
"defrost": {
"value": "on",
"timestamp": "2020-01-19T18:58:40.000+0000"
},
"rapidCooling": {
"value": "Off",
"timestamp": "2020-01-19T18:58:39.962+0000"
},
"rapidFreezing": {
"value": "Off",
"timestamp": "2020-01-19T18:58:39.970+0000"
}
},
"custom.deodorFilter": {
"deodorFilterCapacity": {
"value": null,
"timestamp": "2020-06-06T23:48:58.146+0000"
},
"deodorFilterStatus": {
"value": null,
"timestamp": "2020-06-05T01:44:01.569+0000"
},
"deodorFilterResetType": {
"value": null,
"timestamp": "2020-06-04T16:57:51.803+0000"
},
"deodorFilterUsage": {
"value": null,
"timestamp": "2020-06-04T16:52:10.609+0000"
},
"deodorFilterUsageStep": {
"value": null,
"timestamp": "2020-06-04T14:38:01.693+0000"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [
"powerConsumptionReport",
"custom.deodorFilter",
"custom.waterFilter"
],
"timestamp": "2020-01-19T18:58:40.082+0000"
}
},
"temperatureMeasurement": {
"temperature": {
"value": 37,
"unit": "F",
"timestamp": "2020-09-10T01:40:52.100+0000"
}
},
"custom.deviceReportStateConfiguration": {
"reportStateRealtimePeriod": {
"value": null,
"timestamp": "2020-06-03T23:30:32.065+0000"
},
"reportStateRealtime": {
"value": null,
"timestamp": "2020-06-03T22:23:05.392+0000"
},
"reportStatePeriod": {
"value": null,
"timestamp": "2020-06-03T16:38:57.341+0000"
}
},
"custom.waterFilter": {
"waterFilterUsageStep": {
"value": null,
"timestamp": "2020-06-03T16:05:36.116+0000"
},
"waterFilterResetType": {
"value": null,
"timestamp": "2020-06-03T15:12:04.032+0000"
},
"waterFilterCapacity": {
"value": null,
"timestamp": "2020-06-03T15:06:12.006+0000"
},
"waterFilterUsage": {
"value": null,
"timestamp": "2020-06-03T14:43:47.526+0000"
},
"waterFilterStatus": {
"value": null,
"timestamp": "2020-06-03T13:34:18.505+0000"
}
}
}
}
}
@andrewsayre Thank you for all your great work on this plugin! I as well would like to be able to see and control device components for my refrigerator (I can't get or set the temperature currently in HomeAssistant). Do you have any suggestions for how to go about adding this feature? Would you be willing to review a PR that attempts to do such? I'm currently working around this issue with raw curl requests to the smart things API for reading back values and have no working workaround for setting values (although I probably could also use curls, I'd rather spend time trying to enhance this valuable community plugin then reinventing the wheel further).
Thanks!
Are you missing the temperature sensor completely? As for controlling the device take a look at https://github.com/veista/smartthings. I can add the missing functions there with your help.

The actual values are nested under "cooler" and freezer" apiResult.json.zip apiResult.txt
@veista is your package a drop-in replacement for this one? I'd prefer to try to work on enhancing this package if the dev is open to continuing to advance it before switching to a fork, but if this package is not actively developed/supported that's definitely an option
is your package a drop-in replacement for this one?
It's a drop-in replacement for the SmartThings integration in Home Assistant, it utilizes this library.
@veista have you considered dropping some PRs into core to upgrade the component?
I'll defiantly be giving your component a shot.
There are only a few minor bugs worth updating. Otherwise they will not be accepted to the main dev.
I'll defiantly be giving your component a shot.
You may be as defiant as you wish. I waited a couple of years for these features in vain as did many others.
lol sorry that was supposed to be "definitely"
Otherwise they will not be accepted to the main dev.
As the maintainer of this library, I'm not sure what you're referring to. I'd welcome PRs to add component support or other mainline features.
@andrewsayre I am referring to custom. Components and comparable capabilities that you have refused to add to the library due to not being in ST standard. This is good news. This problem indeed is not related directly to previous ones.
Can you explain to me two things though.
- How are capabilities outside of "main" overriding capabilities in "main"
- If there are two attributes with the same name in different capabilities, the other one is ignored
Components and comparable capabilities that you have refused to add to the library due to not being in ST standard.
That's my position on adding convenience members for "custom capabilities" (there isn't such a thing as custom components). Capabilities are a dynamic element and "custom" capabilities particularly can be changed at-will, hence why adding convenience methods and constants for them would create too much overhead to maintain. Those constants are just strings and the convenience methods are just wrappers that use strings to access dictionary values or post a device command. The library already provides everything needed to utilize and interact with ANY capability--custom or not.
- How are capabilities outside of "main" overriding capabilities in "main"
It is not an overriding or shadowing concept. Each component is essentially a dictionary of values. "main" is the "default" dictionary of attribute values. It's a legacy artifact from before ST had multicomponent devices to treat them as top-level/default attributes (which this library does with the convenience members--another reason not to keep perpetuating this pattern).
- If there are two attributes with the same name in different capabilities, the other one is ignored
It's not ignored. Within each component, there can only be one district value for an attribute (just like a dictionary). Whatever value is set for the attribute will be the value for any capability that has an attribute with the same name in the same component. This does mean you can't have colliding attributes with different values -- updates to them would replace the previous value. This is a legacy behavior, which I'm not sure is true anymore. Attribute values are nested under their component, so it's possible you can have the same attribute name under different capabilities with different values.
One suggestion I have would be to study the SmartThings Core SDK. That library exposes the ST concepts properly and is ultimately how this library should be modeled/advanced to.
Yes. Sorry, I meant custom. Capabilities. I understand this, and that is what I was refering to. I think the problem I ran in previously is anwsered in 2. This is most certainly not true anymore. I have tried to study the SmartThings core. Most issues arise from samsung not using this in their own devices.
And as for question 1: in firstof9's case he has a null value in temperatureMeasurement showing in HA, but "main" has a valid value for that capability. Im assuming it is overwritten by component "cvroom"'s temperatureMeasurement. I will try to confirm this behaviour.
I understood from your code that capabilities from "main" are used. Correct me if I am wrong.
Otherwise they will not be accepted to the main dev.
As the maintainer of this library, I'm not sure what you're referring to. I'd welcome PRs to add component support or other mainline features.
Also I was refering to my fork of the HA integration.
in firstof9's case he has a null value in temperatureMeasurement showing in HA, but "main" has a valid value for that capability. Im assuming it is overwritten by component "cvroom"'s temperatureMeasurement.
Since this is an old dump, the temperatureMeasurement
under main
is now reporting null
.
Since this is an old dump, the temperatureMeasurement under main is now reporting null.
Thanks for that update. There dones't appear to be a mystery here. For whatever reason, the device is reporting no value/null and the library and Home Assistant integration are updating accordingly.
My approach to try to keep backwards compatibility with HA was probably going to be something along the lines of turning each component into its own device. That would "fix" the issue of a single device having the same capability in multiple components, but could introduce issues with duplicate IDs. Alternatively, one could try to truly support multiple components fully under a single device. Would that break Home assistant?
Since this is an old dump, the temperatureMeasurement under main is now reporting null.
Thanks for that update. There dones't appear to be a mystery here. For whatever reason, the device is reporting no value/null and the library and Home Assistant integration are updating accordingly.
Yes, I was just assuming as I stated, with the information that was given. Sorry for the confusion.
Here's a new dump:
{
"components": {
"icemaker": {
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": null
}
},
"switch": {
"switch": {
"value": "on",
"timestamp": "2021-10-31T04:45:37.879Z"
}
}
},
"cooler": {
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2022-01-18T20:13:23.156Z"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [],
"timestamp": "2021-07-27T01:19:43.145Z"
}
},
"temperatureMeasurement": {
"temperature": {
"value": 37,
"unit": "F",
"timestamp": "2022-01-11T01:43:48.635Z"
}
},
"custom.thermostatSetpointControl": {
"minimumSetpoint": {
"value": 34,
"unit": "F",
"timestamp": "2021-07-27T01:19:42.452Z"
},
"maximumSetpoint": {
"value": 44,
"unit": "F",
"timestamp": "2021-07-27T01:19:42.452Z"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpoint": {
"value": 37,
"unit": "F",
"timestamp": "2021-07-27T01:19:42.452Z"
}
}
},
"freezer": {
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2022-01-18T19:58:59.613Z"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [],
"timestamp": "2021-07-27T01:19:43.145Z"
}
},
"temperatureMeasurement": {
"temperature": {
"value": 0,
"unit": "F",
"timestamp": "2021-12-19T05:08:29.876Z"
}
},
"custom.thermostatSetpointControl": {
"minimumSetpoint": {
"value": -8,
"unit": "F",
"timestamp": "2021-07-27T01:19:42.452Z"
},
"maximumSetpoint": {
"value": 5,
"unit": "F",
"timestamp": "2021-07-27T01:19:42.452Z"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpoint": {
"value": 0,
"unit": "F",
"timestamp": "2021-07-27T01:19:42.452Z"
}
}
},
"main": {
"custom.disabledComponents": {
"disabledComponents": {
"value": [
"icemaker-02"
],
"timestamp": "2021-07-27T01:19:43.145Z"
}
},
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2022-01-18T20:13:23.156Z"
}
},
"powerConsumptionReport": {
"powerConsumption": {
"value": {
"energy": 1815132,
"deltaEnergy": 34,
"power": 153,
"powerEnergy": 34.42290833294392,
"persistedEnergy": 0,
"energySaved": 0,
"start": "2022-01-18T20:06:20Z",
"end": "2022-01-18T20:20:23Z"
},
"timestamp": "2022-01-18T20:20:23.018Z"
}
},
"samsungce.viewInside": {
"contents": {
"value": [],
"timestamp": "2021-11-11T11:40:55.468Z"
},
"lastUpdatedTime": {
"value": "2022-01-18T20:13:31Z",
"timestamp": "2022-01-18T20:13:32.030Z"
}
},
"refresh": {},
"execute": {
"data": {
"value": {
"payload": {
"rt": [
"x.com.samsung.da.energyconsumption"
],
"if": [
"oic.if.a"
],
"x.com.samsung.da.cumulativePower": "1815132",
"x.com.samsung.da.cumulativeUnit": "Wh",
"x.com.samsung.da.instantaneousPower": "153",
"x.com.samsung.da.instantaneousPowerUnit": "W",
"x.com.samsung.da.monthlyConsumption": "72000",
"x.com.samsung.da.thismonthlyConsumption": "38832"
}
},
"data": {
"href": "/energy/consumption/vs/0"
},
"timestamp": "2022-01-18T20:20:23.018Z"
}
},
"custom.fridgeMode": {
"fridgeModeValue": {
"value": null
},
"fridgeMode": {
"value": null
}
},
"ocf": {
"st": {
"value": "2021-11-25T11:41:19Z",
"timestamp": "2021-12-02T11:41:36.995Z"
},
"mndt": {
"value": "",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnfv": {
"value": "20210813.115026",
"timestamp": "2021-08-25T13:20:27.463Z"
},
"mnhw": {
"value": "",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"di": {
"value": "7d3feb98-8a36-4351-c362-5e21ad3a78dd",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnsl": {
"value": "",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"dmv": {
"value": "res.1.1.0,sh.1.1.0",
"timestamp": "2021-12-02T11:41:36.995Z"
},
"n": {
"value": "[refrigerator] Samsung (LCD)",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnmo": {
"value": "21K_REF_LCD_FHUB6.0|00113141|0002034e051324200103000000000000",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"vid": {
"value": "DA-REF-NORMAL-01001",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnmn": {
"value": "Samsung Electronics",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnml": {
"value": "",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnpv": {
"value": "6.0",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"mnos": {
"value": "Tizen",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"pi": {
"value": "7d3feb98-8a36-4351-c362-5e21ad3a78dd",
"timestamp": "2021-07-27T01:19:42.234Z"
},
"icv": {
"value": "core.1.1.0",
"timestamp": "2021-07-27T01:19:42.234Z"
}
},
"refrigeration": {
"defrost": {
"value": "off",
"timestamp": "2021-07-27T01:19:42.945Z"
},
"rapidCooling": {
"value": "off",
"timestamp": "2021-07-27T01:19:42.715Z"
},
"rapidFreezing": {
"value": "off",
"timestamp": "2021-07-27T01:19:42.715Z"
}
},
"samsungce.powerCool": {
"activated": {
"value": false,
"timestamp": "2021-07-27T01:19:42.715Z"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [
"custom.deviceReportStateConfiguration"
],
"timestamp": "2021-07-27T01:19:43.145Z"
}
},
"samsungce.driverVersion": {
"versionNumber": {
"value": 21061601,
"timestamp": "2021-11-29T02:07:32.214Z"
}
},
"samsungce.powerFreeze": {
"activated": {
"value": false,
"timestamp": "2021-07-27T01:19:42.715Z"
}
},
"temperatureMeasurement": {
"temperature": {
"value": null
}
},
"custom.deviceReportStateConfiguration": {
"reportStateRealtimePeriod": {
"value": null
},
"reportStateRealtime": {
"value": {
"state": "disabled"
},
"timestamp": "2021-07-27T01:19:42.757Z"
},
"reportStatePeriod": {
"value": "enabled",
"timestamp": "2021-07-27T01:19:42.757Z"
}
},
"custom.waterFilter": {
"waterFilterUsageStep": {
"value": 1,
"timestamp": "2021-11-29T02:21:18.647Z"
},
"waterFilterResetType": {
"value": [
"replaceable"
],
"timestamp": "2021-11-29T02:21:18.647Z"
},
"waterFilterCapacity": {
"value": null
},
"waterFilterLastResetDate": {
"value": null
},
"waterFilterUsage": {
"value": 43,
"timestamp": "2022-01-17T01:48:22.020Z"
},
"waterFilterStatus": {
"value": "normal",
"timestamp": "2021-11-29T02:21:18.647Z"
}
},
"thermostatCoolingSetpoint": {
"coolingSetpoint": {
"value": null
}
}
},
"cvroom": {
"custom.fridgeMode": {
"fridgeModeValue": {
"value": null
},
"fridgeMode": {
"value": "CV_FDR_DELI",
"timestamp": "2021-07-27T01:19:42.702Z"
}
},
"contactSensor": {
"contact": {
"value": "closed",
"timestamp": "2022-01-18T20:01:01.895Z"
}
},
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": [],
"timestamp": "2021-07-27T01:19:43.145Z"
}
}
},
"icemaker-02": {
"custom.disabledCapabilities": {
"disabledCapabilities": {
"value": null
}
},
"switch": {
"switch": {
"value": null
}
}
}
}
}
Should be fixed with #77 and https://github.com/home-assistant/core/pull/99924