home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.05k stars 29.71k forks source link

Smartthings Device with 3 Components ==> Missing Switches / Sensors #91892

Closed thomas-coenen closed 1 week ago

thomas-coenen commented 1 year ago

The problem

I have a Heat pump with Samsung Wifi Kit. In the Smartthings App everything is working properly. The Heat pump is one device with 3 components. Warm Water, Normal Heating (INDOOR1) and Floor Heating (INDOOR2). In Home assistant I can only see the switch and actual values for the Warm Water. Please find the infos got by SmartthingsCLI below:

Main Info
───────────────────────────────────────────────────────────────
 Label                   Eco Heating System
 Name                    Eco Heating System
 Id                      xxx
 Type                    OCF
 Manufacturer Code       Samsung Electronics
 Location Id             xxx
 Room Id                 xxx
 Profile Id              xxx
 Capabilities            ocf
                         switch
                         temperatureMeasurement
                         thermostatCoolingSetpoint
                         thermostatHeatingSetpoint
                         airConditionerMode
                         powerConsumptionReport
                         demandResponseLoadControl
                         remoteControlStatus
                         refresh
                         execute
                         custom.energyType
                         custom.outingMode
                         custom.thermostatSetpointControl
                         custom.deviceReportStateConfiguration
                         custom.disabledCapabilities
                         samsungce.deviceIdentification
                         samsungce.driverVersion
                         samsungce.sacDisplayCondition
                         samsungce.softwareUpdate
                         samsungce.ehsFsvSettings
                         samsungce.ehsCycleData
                         samsungce.ehsTemperatureReference
                         samsungce.ehsThermostat
 Capabilities (INDOOR1)  switch
                         temperatureMeasurement
                         thermostatCoolingSetpoint
                         airConditionerMode
                         custom.thermostatSetpointControl
                         samsungce.ehsTemperatureReference
                         samsungce.ehsThermostat
                         samsungce.sacDisplayCondition
 Capabilities (INDOOR2)  switch
                         temperatureMeasurement
                         thermostatCoolingSetpoint
                         airConditionerMode
                         custom.thermostatSetpointControl
                         samsungce.ehsTemperatureReference
                         samsungce.ehsThermostat
                         samsungce.sacDisplayCondition
───────────────────────────────────────────────────────────────

There was a similar issue (#83136), but it has been closed by the bot.

What version of Home Assistant Core has the issue?

core-2023.4.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

SmartThings

Link to integration documentation on our website

https://www.home-assistant.io/integrations/smartthings/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @andrewsayre, mind taking a look at this issue as it has been labeled with an integration (smartthings) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `smartthings` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign smartthings` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


smartthings documentation smartthings source (message by IssueLinks)

thomas-coenen commented 1 year ago

@andrewsayre Hey Andrew,

Do you have any idea how to solve this issue? I would appreciate your contribution.

Best regards, Thomas

andrewsayre commented 1 year ago

Device Components are not currently supported in the integration. This isn't an issue, but a feature request.

TheSimpleZ commented 1 year ago

I have a similar setup, except I only use one of the zones called INDOOR which is also missing. I'm also missing the ability to control any of the setpoints or modes on the main component. I can only read the values. Could you consider this issue a feature request or would you like for us to open a thread in the forums?

dwradcliffe commented 12 months ago

I have a PR which adds support for components: https://github.com/home-assistant/core/pull/99924

moebis commented 12 months ago

I have a PR which adds support for components: #99924

Hi David, is there a way I could install/test this now? They are saying on the discord it could take months for the PR.

dwradcliffe commented 12 months ago

Hi David, is there a way I could install/test this now? They are saying on the discord it could take months for the PR.

Yep, I'm doing that. I placed my version of the smartthings component directory in my custom_components directory and also my version of pysmartthings in my root config directory. It should just pick them up and work. Let me know if you have any issues.

mrkaqz commented 12 months ago

Hi David, is there a way I could install/test this now? They are saying on the discord it could take months for the PR.

Yep, I'm doing that. I placed my version of the smartthings component directory in my custom_components directory and also my version of pysmartthings in my root config directory. It should just pick them up and work. Let me know if you have any issues.

Sorry, can you explain more on the step to put pysmartthings in the root config directory. I cannot find the file called pysmartthings anywhere else in your version. I have put smartthings directory in my custom_components and restart HA but it seem noting happen.

dwradcliffe commented 12 months ago

The pysmartthings library with my changes is https://github.com/andrewsayre/pysmartthings/pull/77 Note that it's not the whole repo, but just the inner pysmartthings directory.

TheSimpleZ commented 11 months ago

I tried your fork, but I'm getting this error in the logs and the integration won't start:

Error setting up entry Home for smartthings
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/smartthings/__init__.py", line 125, in async_setup_entry
    token = await api.generate_tokens(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/pysmartthings/smartthings.py", line 209, in generate_tokens
    result = await self._service.generate_tokens(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/pysmartthings/api.py", line 424, in generate_tokens
    raise APIInvalidGrant(data.get("error_description"))
pysmartthings.errors.APIInvalidGrant: Empty scope (either the client or the user is not allowed the requested scopes)

EDIT: It seem like the error was fixed by removing the smartthings integration and setting it up again through the homeassistant ui. ~However, I still don't see the sensors from any other component but the main one.~ It also seems like the manifest is missing the "version" property which prevents the integration from loading. Just add any dummy version in the manifest and you should be good to go!

mrkaqz commented 11 months ago

I tried your fork, but I'm getting this error in the logs and the integration won't start:

Error setting up entry Home for smartthings
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/smartthings/__init__.py", line 125, in async_setup_entry
    token = await api.generate_tokens(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/pysmartthings/smartthings.py", line 209, in generate_tokens
    result = await self._service.generate_tokens(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/pysmartthings/api.py", line 424, in generate_tokens
    raise APIInvalidGrant(data.get("error_description"))
pysmartthings.errors.APIInvalidGrant: Empty scope (either the client or the user is not allowed the requested scopes)

EDIT: It seem like the error was fixed by removing the smartthings integration and setting it up again through the homeassistant ui. ~However, I still don't see the sensors from any other component but the main one.~ It also seems like the manifest is missing the "version" property which prevents the integration from loading. Just add any dummy version in the manifest and you should be good to go!

Yeap, mine works now, need to add version to the manifest file. Thanks. So far it show up correctly. Hope this PR will merge soon.

thomas-coenen commented 11 months ago

Hi @dwradcliffe,

nice to hear that you have a solution. Putting the smart things folder to custom_components will atumatically "override" the original? Where exactly do I have to put the "pysmartthings". Directly under "config" into folder "pysmartthings"? The complete repository or just the files you changed? Will it also override the original? Is there a nice way to do so, or do I have to download the code and copy it?

Thank you for help. Regards, Thomas

mrkaqz commented 11 months ago

Yes, pysmartthings can put directly on config folder as a whole directly but make sure edit manifest file in smartthings custom_conponents folder by adding version to it as well. Any version number will do.

On Tue, 19 Sept 2023, 02:37 thomas-coenen, @.***> wrote:

Hi @dwradcliffe https://github.com/dwradcliffe,

nice to hear that you have a solution. Putting the smart things folder to custom_components will atumatically "override" the original? Where exactly do I have to put the "pysmartthings". Directly under "config" into folder "pysmartthings"? The complete repository or just the files you changed? Will it also override the original? Is there a nice way to do so, or do I have to download the code and copy it?

Thank you for help. Regards, Thomas

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/91892#issuecomment-1724166468, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVKQU75P5FPNULCM5TVXT3X3CIFXANCNFSM6AAAAAAXIM3JOI . You are receiving this because you commented.Message ID: @.***>

thomas-coenen commented 11 months ago

I managed to get it working. All sensors are now available. Well done. Unfortunately all temperature set points are also only sensors which cannot be set. Any ideas for that?

thomas-coenen commented 11 months ago

Hi @dwradcliffe ,

i have another issue. My Heatpump is integrated as an Airconditioner but does not support FAN Mode. I removed it from the list of necessary features. That worked. Unfortunately I can control only the temperature of the first component. Now my question: Can you extend for Pullrequest to also support the climate entity with multiple components. If I saw correct you added for sensors, binary_sensors and switches. That would be awesome.

Best regards, Thomas

dwradcliffe commented 11 months ago

Can you extend for Pullrequest to also support the climate entity with multiple components. If I saw correct you added for sensors, binary_sensors and switches. That would be awesome.

In theory yes but as I don't have anything like that to test locally it's more difficult for me. I may attempt it after I get the first round merged or maybe someone else can pick it up.

moebis commented 11 months ago

How soon will these get merged in? Samsung fridge sensors have been broken in Home Assistant for years (I've found no less than 5 threads going back 2-3 years, multiple pages). Is there a way I can just use this now? Please, thank you.

mrkaqz commented 11 months ago

How soon will these get merged in? Samsung fridge sensors have been broken in Home Assistant for years (I've found no less than 5 threads going back 2-3 years, multiple pages). Is there a way I can just use this now? Please, thank you.

Yep, manually install the fix in following the instruction in above comment. Mine works for weeks now.

adamlc commented 10 months ago

Sadly I haven't had much luck with this custom component. I'm getting the following error. I did try removing and re-adding the integration in home assistant.

I have 2 TVs, 1 Soundbar, 1 Air con and 1 Robot vacuum if that helps

homeassistant  | 2023-10-20 14:31:20.532 ERROR (MainThread) [homeassistant.components.switch] Error while setting up smartthings platform for switch
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
homeassistant  |     await asyncio.shield(task)
homeassistant  |   File "/config/custom_components/smartthings/switch.py", line 28, in async_setup_entry
homeassistant  |     if component in device.status.disabled_components:
homeassistant  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  | AttributeError: 'DeviceStatus' object has no attribute 'disabled_components'
homeassistant  | 2023-10-20 14:31:20.535 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up smartthings platform for binary_sensor
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
homeassistant  |     await asyncio.shield(task)
homeassistant  |   File "/config/custom_components/smartthings/binary_sensor.py", line 60, in async_setup_entry
homeassistant  |     if component in device.status.disabled_components:
homeassistant  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  | AttributeError: 'DeviceStatus' object has no attribute 'disabled_components'
homeassistant  | 2023-10-20 14:31:20.536 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up smartthings platform for sensor
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
homeassistant  |     await asyncio.shield(task)
homeassistant  |   File "/config/custom_components/smartthings/sensor.py", line 565, in async_setup_entry
homeassistant  |     if component in device.status.disabled_components:
homeassistant  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  | AttributeError: 'DeviceStatus' object has no attribute 'disabled_components'
elad-bar commented 7 months ago

Integration is working with main device only, found the issue and working on PR, Managed to add all components related to devices for binary sensor, now working on other ha components.

contemplator1998 commented 7 months ago

Just in case, here is a fixed (at least for me) SmartThings you can install via HACS: https://github.com/contemplator1998/smartthings

(Pulled https://github.com/home-assistant/core/pull/99924 and wrapped into a HACS repo)

It makes everything accessible, even sensors/controls that are always unavailable (just disable them in the HA).

ColinSainsbury commented 7 months ago

Thanks for the work you have done @contemplator1998 in my configuration I was only seeing Indoor 1 (Flow Temperature to Radiators) temperature and set point. I lost the Domestic Hot Water temperature and set point measurements. This is not to be critical, it is to assist @elad-bar in their efforts to develop a pull request that enables all features/sensors of the ASHP which is clearly a complex task. Here's hoping that the relevant entities can be presented to show thermostats even if they are not used as such.

elad-bar commented 7 months ago

I have a solution that should be adopted into the smartthing package, since it's big change (details below) i guess it will take time to deliver it, problem with the approach to open all components without looking into which components are disabled and to have hard-coded mapping of capabilities is that even if additional components will get opened, there will be continous need to update the package, what i'm suggesting is more dynamic approach relaying on the api samiliar to the mobile app, mapping to complex HA components should be done in the level of HA component and not the package.

below are the main focus of what i have done and shared in my repo elad-bar/dynamic-smart-things.

General functionality representing the integration dyanmically:

Functionality that should be available for HA:

ColinSainsbury commented 7 months ago

Is there a way that I could trial this? I have got used to testing other HACS SmartThings integrations but I am not sure this is prepared in that way. I do not have the skill to read your code and review it for you but I am OK to implement it (I back up before changes) and provide feedback against a complex device. I have an EHS Mono Quiet Air Source Heat Pump which should exercise your code.


From: Elad Bar @.> Sent: Thursday, January 18, 2024 11:19 To: home-assistant/core @.> Cc: ColinSainsbury @.>; Comment @.> Subject: Re: [home-assistant/core] Smartthings Device with 3 Components ==> Missing Switches / Sensors (Issue #91892)

I have a solution that should be adopted into the smartthing package, since it's big change (details below) i guess it will take time to deliver it, problem with the approach to open all components without looking into which components are disabled and to have hard-coded mapping of capabilities is that even if additional components will get opened, there will be continous need to update the package, what i'm suggesting is more dynamic approach relaying on the api samiliar to the mobile app, mapping to complex HA components should be done in the level of HA component and not the package.

below are the main focus of what i have done and shared in my repo elad-bar/dynamic-smart-thingshttps://github.com/elad-bar/dynamic-smart-things.

General functionality representing the integration dyanmically:

Functionality that should be available for HA:

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/91892#issuecomment-1898287955, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIBRFMKZ7QWC7VB2MX57Q4TYPEANFAVCNFSM6AAAAAAXIM3JOKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJYGI4DOOJVGU. You are receiving this because you commented.Message ID: @.***>

elad-bar commented 7 months ago

sure, you can download the code and run it locally, all you need to setup is your token as environment variable and run it, It will generate (huge) json file of diagnostics, One of it's properties is the entities it recommends to create in HA

I can work on custom integration so it will be also available in HACS but i will need few more days for that once i will have time for it, hopefully in 2 weeks.

Pls let me know how it works for you

ePiccio commented 7 months ago

Ciao @elad-bar first of all many thanks for your help in this! much appreciated! I have same issue above as Mr ColinSainsbury, before i used to see only hot water, now i only see Indoor 1, and not even properly I would say. have you had any luck on working on that HACS integration you mentioned?

i'm not familiar with how to run your python code so a bit lost on required steps. how could I run the code you posted in my HA? anyone that could please help me by sharing a noob-proof step by step guide? i'm running HA supervised on a Debian Dell mini pc. (and before you ask me how did I get there, i'll say I have been copy/pasting s**tloads of commands blindly :D ) many thanks!!!

elad-bar commented 7 months ago

Hi @ePiccio, didn't get to create custom integration out of that code yet, bit overloaded now, but will work on it as soon as I will be able to promote it, Current integration is great but limited for main component, it requires lot of changes because it has different data model than the API which makes it limited and all actions are pretty hard coded while definitions are part of the API, On the other hand, it supports webhooks to get updates while my code doesn't support it, so that will be the main challenge, will keep you posted once it works

moebis commented 4 months ago

Hi @ePiccio, didn't get to create custom integration out of that code yet, bit overloaded now, but will work on it as soon as I will be able to promote it, Current integration is great but limited for main component, it requires lot of changes because it has different data model than the API which makes it limited and all actions are pretty hard coded while definitions are part of the API, On the other hand, it supports webhooks to get updates while my code doesn't support it, so that will be the main challenge, will keep you posted once it works

Is this available via HACS now? I would love to test this as the other one by @contemplator1998 doesn't work with power reading on the Samsung Fridges. So we have 2 half solutions. The official HA will report power usage but not temps or set-points and @contemplator1998 HACS plugin will report temps but not power. And if you try to remove one and install the other you end up with a bunch of orphaned or broken entities. Been looking for a solution for over a year now.

Dorf66 commented 4 months ago

I have a PR which adds support for components: #99924

Hi, can you please write me the exact procedure to get all Smartthings entities in Home Assistant? When I use the integration from HA, I only see the options for hot water from the heat pump, when I copy the smartthings folder to the custom_components folder, I only see the entities related to the 2 heating circuits, but again I don't see the hot water options.

wawyed commented 4 months ago

Hi, I just had a ASHP installed and I've love to create automations on it with hot water and heating. Are there any options to support this?

EDIT: For anyone interested I've managed to use the Smartthings API and the Restful sensor/Restful commands home assistant integration to create my own sensors and climate entity to control the samsung heat pump.

fotodorf commented 3 months ago

Hi, can you please write the exact instructions? Thank you.

wawyed commented 3 months ago

Hi, can you please write the exact instructions? Thank you.

I posted them here https://github.com/home-assistant/core/issues/101265#issuecomment-2112170271

Dorf66 commented 3 months ago

Again: Hi, can you please write me the exact procedure to get all Smartthings entities in Home Assistant? When I use the integration from HA, I only see the options for hot water from the heat pump, when I copy the smartthings folder to the custom_components folder, I only see the entities related to the 2 heating circuits, but again I don't see the hot water options.

issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.