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
73.56k stars 30.73k forks source link

Smartthings integration: Samsung fridge sensors status doesn't update in States or frontend #26230

Closed ronschaeffer closed 4 years ago

ronschaeffer commented 5 years ago

Home Assistant release with the issue: 0.97.2

Last working Home Assistant release (if known): Never tried with an earlier version

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io

Component/platform: Smartthings https://www.home-assistant.io/components/smartthings/

Description of problem:

I’ve just added a Samsung BRB260087WW fridge/freezer to an existing Smartthings integration in 0.97.2

Three sensors show up in HA, but they never update in either States or in the frontend. I can see in the log that HA is at least receiving open/close status for the doors, even if the state of the relevant device never changes.

States:

binary_sensor.refrigerator_contact        off       friendly_name: Refrigerator contact
device_class: opening

binary_sensor.refrigerator_filterstatus     off     friendly_name: Refrigerator filterStatus
device_class: problem

sensor.refrigerator_temperature_measurement unknown friendly_name: Refrigerator Temperature Measurement
device_class: temperature

In the frontend:

image

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

None

Traceback (if applicable):

No error/traceback visible in log, but here is a relevant excerpt showing that status updates are received.

2019-08-23 13:47:36 DEBUG (MainThread) [homeassistant.components.smartthings.smartapp] Subscriptions for app 'xxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx' are up-to-date
2019-08-23 13:49:07 DEBUG (MainThread) [homeassistant.components.smartthings] Push update received: {'location_id': 'xxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx', 'device_id': 'xxxxxxxx-xxxx-0000-0000-000000000000', 'component_id': 'main', 'capability': 'execute', 'attribute': 'data', 'value': {'payload': {'id': '0', 'x.com.samsung.da.openState': 'Close'}}, 'data': None}
2019-08-23 13:49:07 DEBUG (MainThread) [homeassistant.components.smartthings] Push update received: {'location_id': 'xxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx', 'device_id': 'xxxxxxxx-xxxx-0000-0000-000000000000', 'component_id': 'main', 'capability': 'execute', 'attribute': 'data', 'value': {'payload': {'id': '1', 'x.com.samsung.da.openState': 'Open'}}, 'data': None}
2019-08-23 13:49:35 DEBUG (MainThread) [homeassistant.components.smartthings] Push update received: {'location_id': 'xxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx', 'device_id': 'xxxxxxxx-xxxx-0000-0000-000000000000', 'component_id': 'main', 'capability': 'execute', 'attribute': 'data', 'value': {'payload': {'id': '1', 'x.com.samsung.da.openState': 'Close'}}, 'data': None}

Additional information:

andrewsayre commented 5 years ago

Can you confirm that in the SmartThings IDE, the events (states) do not display there either? You can view this by navigating into one of the devices and clicking the events link. My assumption is that the states don't show up there either.

CC @dbradmit

dbradmit commented 5 years ago

Based on the device id format of "xxxxxxxx-xxxx-0000-0000-000000000000", this is a legacy device integration and the events from these devices often come through differently and don't map as you'd expect.

For example: https://graph-eu01-euwest1.api.smartthings.com/device/states/xxxxxxxx-xxxx-0000-0000-000000000000?attribute=data

Screen Shot 2019-08-27 at 6 25 19 PM
ronschaeffer commented 5 years ago

Thanks, @andrewsayre & @dbradmit.

Can you confirm that in the SmartThings IDE, the events (states) do not display there either? You can view this by navigating into one of the devices and clicking the events link. My assumption is that the states don't show up there either.

The state of the door shows up in the Smartthings IDE. The temperature and filter status do not--unless maybe they will only show on a state change. The door happens to be the only state that I really care about for HA, but it would be nice to have all three sensors working.

The Current States field indeed looks like @dbradmit 's example, except that there is no "x.com.samsung.da.name" key.

{
    "payload": {
        "id": "1",
        "x.com.samsung.da.openState": "Open"
    }
}

image

Looking at "List Events," there is versionNumber event including a deviceTypeId of 5ce8f920-4075-4a14-b513-497b12d85f10 that looks like this, in case it is relevant:

image

andrewsayre commented 5 years ago

@ronschaeffer so I want to clarify a few things... The data attribute does not represent the state of the device -- it's essentially used to pass in data/commands instead of using the standard capabilities and it can't be used by HA or other third part apps to obtain the state of the device or control it. If you look closely at the logs posted, you'll see the push updates are for the execute capability and data attribute, which unfortunately, are irrelevant. What you want to be looking for is a push update under the specific capability (contactSensor, filterStatus, or temperatureMeasurement), which this device isn't sending.

@dbradmit Is there any work around for these legacy devices?

ronschaeffer commented 5 years ago

Thanks, @andrewsayre. I understand the distinction you're making. As a possible workaround, is there any way to access the received push updates in HA so as to use them as the basis for a template sensor?

andrewsayre commented 5 years ago

Unfortunately not at this time. Let's see if we can come up with a workaround with Brad, otherwise we could consider exposing the push updates as events in HA as a alternative.

ronschaeffer commented 5 years ago

OK, thanks. Just let me know if you need me to test anything.

dbradmit commented 5 years ago

I spoke with an engineer and it seems the issue is with the mapping the states for the Wi-fi dongle devices. This should be addressed in the future but unfortunately there isn't a timeline as to when.

ronschaeffer commented 5 years ago

Thank you for looking into it, @dbradmit.

Happy to treat if you do decide to expose the push updates as events.

andrewsayre commented 5 years ago

@ronschaeffer I will make the change on the HA side to expose the push updates on the HA event bus. Just know it’s not going to solve your problem fully.

andrewsayre commented 5 years ago

@ronschaeffer PR submitted to add the event functionality.

ronschaeffer commented 5 years ago

Thanks. Looking forward to trying it.

On Sat, Sep 7, 2019 at 9:07 PM Andrew Sayre notifications@github.com wrote:

@ronschaeffer https://github.com/ronschaeffer PR submitted to add the event functionality.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/26230?email_source=notifications&email_token=AC6OOE5YBDN6CC6VC7KJOMLQIP3XVA5CNFSM4IQEHZ6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6FABOQ#issuecomment-529137850, or mute the thread https://github.com/notifications/unsubscribe-auth/AC6OOE7F6MCWM4O7DXCO74DQIP3XVANCNFSM4IQEHZ6A .

ludoergosum commented 5 years ago

I have the same issue, temperature = unknown, while the door sensors works. Could one of you please provide a bit "noob friendly advice" on how I get the temperature implemented given what you wrote above?

Twsts commented 4 years ago

Looking for a solution for this too. Anyone got it working?

ludoergosum commented 4 years ago

I'm still havibnng this issue, Made the purchase of a "smart" samsung product pointless...

stale[bot] commented 4 years 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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

mrlime commented 4 years ago

It looks like the PR to add the event functionality was closed before being finished. Any chance at finishing it?

Apparently I also have a "legacy" fridge. I can see debug messages in my HA log file showing "Push update received" with JSON data that I can decipher indicates that a certain door has been opened or closed, but there don't seem to be any actual events raised in Home Assistant Core.

matlimatli commented 4 years ago

@andrewsayre Do you have any further plans regarding this? You closed the PR, seemingly temporarily, but then nothing more happened.

fhedstrom commented 4 years ago

I am having a similar issue but my fridge works with temp and state door open but not when closed. My fridge works only with state door open but not closed and no temp. When I log into smart things tho everything works there..

mohesles commented 4 years ago

+1 here. Not working for me.

bobo2bobo commented 3 years ago

+1 also not working for me door = working temp = not working

dakahler commented 3 years ago

I am seeing this as well with a new fridge.

Coolie1101 commented 3 years ago

Same here as well, even the manufacturer and model is unavailable/unknown., would be nice to get the door left open notification as well.

image

image

Coolie1101 commented 3 years ago

Same here as well, even the manufacturer and model is unavailable/unknown., would be nice to get the door left open notification as well.

image

image

ludoergosum commented 3 years ago

image The temperature is not integrated correctly

tango2590 commented 2 years ago

Same here

matlimatli commented 2 years ago

As a workaround for getting the temperature from my freezer, I used a rest sensor and a template sensor. I haven't really had the time to look into the real integration. If someone is interested, my current config looks like this:


  - platform: rest
    name: Frys 2
    resource: https://api.smartthings.com/v1/devices/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/status
    headers:
      Authorization: !secret smartthingstoken
    json_attributes:
      - "components"
    value_template: 'OK'

  - platform: template
    sensors:
      freezer_temperature:
        value_template: '{{ states.sensor.frys_2.attributes["components"]["freezer"]["temperatureMeasurement"]["temperature"]["value"] }}'
        device_class: temperature
        unit_of_measurement: '°C'
      freezer_rapidcooling:
        value_template: '{{ states.sensor.frys_2.attributes["components"]["main"]["refrigeration"]["rapidFreezing"]["value"] }}'
      freezer_cooling_setpoint:
        value_template: '{{ states.sensor.frys_2.attributes["components"]["freezer"]["thermostatCoolingSetpoint"]["coolingSetpoint"]["value"] }}'
        device_class: temperature
        unit_of_measurement: '°C'```
Coolie1101 commented 2 years ago

Hey @matlimatli, thanks for sharing, just added your workaround but I'm not getting any attributes, any idea what mite be happening?

image

matlimatli commented 2 years ago

Not really. Perhaps you could have a look in your log files. Also, ensure you have replaced the xxxxxx strings in my example with your device id. If you are unsure about the id, you can log in at http://graph.api.smartthings.com/ and go to "My Locations" and find a link to your device containing the id. Also ensure the authorization token is correct. If you don't have your token, you can generate a new token at https://account.smartthings.com/tokens

Coolie1101 commented 2 years ago

Got it, I guess my initial question should have been what value is x, nevertheless, still no attributes.

The following command line entry returns the info as outlined below with alot more other info listed below, but I have no idea how to extract the data into a sensor, there is also multiple values for temperature with {"value":null} except for the one below, hope this makes sense.

curl --header "Authorization: Bearer smartthings_token" https://api.smartthings.com/v1/devices/device_id/status/


"timestamp":"2021-08-09T05:44:03.987Z"}},"temperatureMeasurement":{"temperature":{"value":34,"unit":"F","timestamp":"2021-11-08T01:42:39.956Z"}}

Complete curl output {"components":{"icemaker":{"custom.disabledCapabilities":{"disabledCapabilities":{"value":null}},"switch":{"switch":{"value":"on","timestamp":"2021-10-21T15:46:51.320Z"}}},"onedoor":{"custom.fridgeMode":{"fridgeModeValue":{"value":null},"fridgeMode":{"value":null}},"contactSensor":{"contact":{"value":null}},"custom.disabledCapabilities":{"disabledCapabilities":{"value":null}},"temperatureMeasurement":{"temperature":{"value":null}},"thermostatCoolingSetpoint":{"coolingSetpoint":{"value":null}}},"cooler":{"custom.fridgeMode":{"fridgeModeValue":{"value":null},"fridgeMode":{"value":null}},"contactSensor":{"contact":{"value":"closed","timestamp":"2021-11-14T20:34:36.667Z"}},"custom.disabledCapabilities":{"disabledCapabilities":{"value":["custom.fridgeMode"],"timestamp":"2021-08-09T05:44:03.987Z"}},"temperatureMeasurement":{"temperature":{"value":34,"unit":"F","timestamp":"2021-11-08T01:42:39.956Z"}},"custom.thermostatSetpointControl":{"minimumSetpoint":{"value":34,"unit":"F","timestamp":"2021-08-09T05:44:02.189Z"},"maximumSetpoint":{"value":44,"unit":"F","timestamp":"2021-08-09T05:44:02.189Z"}},"thermostatCoolingSetpoint":{"coolingSetpoint":{"value":34,"unit":"F","timestamp":"2021-08-09T05:44:02.189Z"}}},"freezer":{"custom.fridgeMode":{"fridgeModeValue":{"value":null},"fridgeMode":{"value":null}},"contactSensor":{"contact":{"value":"closed","timestamp":"2021-11-14T20:34:20.518Z"}},"custom.disabledCapabilities":{"disabledCapabilities":{"value":["custom.fridgeMode"],"timestamp":"2021-08-09T05:44:03.987Z"}},"temperatureMeasurement":{"temperature":{"value":0,"unit":"F","timestamp":"2021-11-07T17:11:09.646Z"}},"custom.thermostatSetpointControl":{"minimumSetpoint":{"value":-8,"unit":"F","timestamp":"2021-08-09T05:44:02.189Z"},"maximumSetpoint":{"value":5,"unit":"F","timestamp":"2021-08-09T05:44:02.189Z"}},"thermostatCoolingSetpoint":{"coolingSetpoint":{"value":0,"unit":"F","timestamp":"2021-08-21T16:44:01.665Z"}}},"main":{"custom.disabledComponents":{"disabledComponents":{"value":["onedoor"],"timestamp":"2021-08-09T05:44:03.987Z"}},"contactSensor":{"contact":{"value":"closed","timestamp":"2021-11-14T20:34:36.667Z"}},"powerConsumptionReport":{"powerConsumption":{"value":{"energy":260427,"deltaEnergy":48,"power":237,"powerEnergy":48.24391554878817,"persistedEnergy":0,"energySaved":0,"start":"2021-11-14T20:35:30Z","end":"2021-11-14T20:47:30Z"},"timestamp":"2021-11-14T20:47:30.664Z"}},"refresh":{},"execute":{"data":{"value":{"payload":{"rt":["x.com.samsung.da.energyconsumption"],"if":["oic.if.baseline","oic.if.a"],"x.com.samsung.da.cumulativeConsumption":"114457","x.com.samsung.da.cumulativePower":"260427","x.com.samsung.da.cumulativeUnit":"Wh","x.com.samsung.da.instantaneousPower":"237","x.com.samsung.da.instantaneousPowerUnit":"W","x.com.samsung.da.monthlyConsumption":"74300","x.com.samsung.da.thismonthlyConsumption":"30427"}},"data":{"href":"/energy/consumption/vs/0"},"timestamp":"2021-11-14T20:47:30.664Z"}},"custom.fridgeMode":{"fridgeModeValue":{"value":null},"fridgeMode":{"value":null}},"ocf":{"st":{"value":null},"mndt":{"value":null},"mnfv":{"value":"A-RFWW-TP2-21-COMMON_20210728","timestamp":"2021-09-29T02:43:05.215Z"},"mnhw":{"value":"MediaTek","timestamp":"2021-08-09T05:44:03.614Z"},"di":{"value":"442c6aae-d9d1-3ff0-b591-fca5112f93b4","timestamp":"2021-08-09T05:44:03.614Z"},"mnsl":{"value":"http://www.samsung.com","timestamp":"2021-08-09T05:44:03.614Z"},"dmv":{"value":"1.2.1","timestamp":"2021-08-09T05:49:50.695Z"},"n":{"value":"[refrigerator] Samsung","timestamp":"2021-08-09T05:44:03.614Z"},"mnmo":{"value":"TP2X_REF_20K|00137641|00000350031513290103010030000000","timestamp":"2021-08-09T05:44:03.614Z"},"vid":{"value":"DA-REF-NORMAL-000001","timestamp":"2021-08-09T05:44:03.614Z"},"mnmn":{"value":"Samsung Electronics","timestamp":"2021-08-09T05:44:03.614Z"},"mnml":{"value":"http://www.samsung.com","timestamp":"2021-08-09T05:44:03.614Z"},"mnpv":{"value":"DAWIT 2.0","timestamp":"2021-08-09T05:44:03.614Z"},"mnos":{"value":"TizenRT 1.0 + IPv6","timestamp":"2021-08-09T05:44:03.614Z"},"pi":{"value":"442c6aae-d9d1-3ff0-b591-fca5112f93b4","timestamp":"2021-08-09T05:44:03.614Z"},"icv":{"value":"core.1.1.0","timestamp":"2021-08-09T05:44:03.614Z"}},"refrigeration":{"defrost":{"value":"off","timestamp":"2021-08-09T05:44:01.238Z"},"rapidCooling":{"value":"off","timestamp":"2021-08-09T05:44:00.793Z"},"rapidFreezing":{"value":"off","timestamp":"2021-10-19T06:20:17.493Z"}},"custom.deodorFilter":{"deodorFilterLastResetDate":{"value":null},"deodorFilterCapacity":{"value":null},"deodorFilterStatus":{"value":null},"deodorFilterResetType":{"value":null},"deodorFilterUsage":{"value":null},"deodorFilterUsageStep":{"value":null}},"samsungce.powerCool":{"activated":{"value":false,"timestamp":"2021-08-09T05:44:00.793Z"}},"custom.disabledCapabilities":{"disabledCapabilities":{"value":["custom.deodorFilter"],"timestamp":"2021-08-09T05:44:03.987Z"}},"samsungce.driverVersion":{"versionNumber":{"value":21060201,"timestamp":"2021-08-09T05:44:00.615Z"}},"samsungce.powerFreeze":{"activated":{"value":false,"timestamp":"2021-10-19T06:20:17.493Z"}},"temperatureMeasurement":{"temperature":{"value":null}},"custom.deviceReportStateConfiguration":{"reportStateRealtimePeriod":{"value":null},"reportStateRealtime":{"value":{"state":"disabled"},"timestamp":"2021-11-03T12:19:06.961Z"},"reportStatePeriod":{"value":"enabled","timestamp":"2021-08-09T05:44:00.822Z"}},"custom.waterFilter":{"waterFilterUsageStep":{"value":1,"timestamp":"2021-08-09T05:44:01.396Z"},"waterFilterResetType":{"value":["replaceable"],"timestamp":"2021-08-09T05:44:01.396Z"},"waterFilterCapacity":{"value":null},"waterFilterLastResetDate":{"value":null},"waterFilterUsage":{"value":55,"timestamp":"2021-11-14T20:30:26.441Z"},"waterFilterStatus":{"value":"normal","timestamp":"2021-08-09T05:44:01.396Z"}},"thermostatCoolingSetpoint":{"coolingSetpoint":{"value":null}}},"cvroom":{"custom.fridgeMode":{"fridgeModeValue":{"value":null},"fridgeMode":{"value":"CV_TTYPE_RF9000A_FREEZE","timestamp":"2021-10-17T04:22:47.642Z"}},"contactSensor":{"contact":{"value":"closed","timestamp":"2021-08-09T05:44:01.439Z"}},"custom.disabledCapabilities":{"disabledCapabilities":{"value":["temperatureMeasurement","thermostatCoolingSetpoint"],"timestamp":"2021-08-09T05:44:03.987Z"}},"temperatureMeasurement":{"temperature":{"value":null}},"thermostatCoolingSetpoint":{"coolingSetpoint":{"value":null}}},"icemaker-02":{"custom.disabledCapabilities":{"disabledCapabilities":{"value":null}},"switch":{"switch":{"value":"on","timestamp":"2021-08-09T05:44:01.421Z"}}}}}

matlimatli commented 2 years ago

Yes, my example was for a freezer, and you seem to have a fridge. There appears to be a temperature measurement at 34 F available. So you could probably do something like

  - platform: template
    sensors:
      fridge_temperature:
        value_template: '{{ states.sensor.frys_2.attributes["components"]["cooler"]["temperatureMeasurement"]["temperature"]["value"] }}'
        device_class: temperature
        unit_of_measurement: '°F'

But this assumes that your frys_2 sensor gets the attributes from the REST API. It should, provided everything is right with the authorization etc, since your curl output seems just fine.

(You might want to use a better name than "Frys", as it is Swedish for "freezer", but that's not important in any way)

Coolie1101 commented 2 years ago

Left it as Frys for testing, It's a combination 4 section Fridge/Freezer as pictured below, what do I use as the initial sensor before applying the template?, I didn't think I can use your rest sensor with a a curl command, and HA config check is not validating with the error below for a command line sensor with the curl command, it doesn't like the upper case "A" in Authorization.

Command Line Sensor command: "curl --header "Authorization: Bearer smartthings_token" https://api.smartthings.com/v1/devices/device_id/status/"

Config Check Error

Error loading /config/configuration.yaml: while parsing a block mapping
in "/config/packages/smartthings.yaml", line 11, column 5
expected <block end>, but found '<scalar>'
in "/config/packages/smartthings.yaml", line 13, column 30

image

matlimatli commented 2 years ago

Ah, yes, I see that you have a freezer temperature available also (the value of 0 got me confused).

My initial sensor is the rest sensor as in my example above. Note that I use Authorization: !secret smartthingstoken, which is the recommended way of handling secrets. You then need to have the text smartthingstoken: "Bearer: yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy" in your secrets.yaml file. Where (yyyy...) is something different than your (xxxx...). Also son't forget the Bearer-part of the secret.

That sensor will make a call similar to your curl call, and stuff everything in the components-part of the json into attributes of the sensor. If it doesn't work, try to check the logs and possibly increase the log level.

image
Coolie1101 commented 2 years ago

Genius!!!, Had it all except for "Bearer:, many many thanks, I am now golden.

image

image

Coolie1101 commented 2 years ago

@matlimatli, Thanks again for all your assistance with this, it really helps, an amazing amount of useful info is available via this sensor.

Cooler Door = closed
Cooler Temp = 34
Cooler Min Set = 34
Cooler Max set = 44
Cooler set = 34

Freezer Door = closed
Freezer Temp = 0
Freezer Min Set = -8
Freezer Max set = 5
Freezer set = 0

Icemaker 1 = on
Icemaker 2 = on

MNFV = A-RFWW-TP2-21-COMMON_20210728
MNFV = 2021-09-29T02:43:05.215Z

Defrost = off
Rapid Cooling = off
Rapid Freezing = off
Samsung CE Version = 21060201
PowerFreeze Activated = False
Water Filter Usage = 55
Water Filter Status = normal

Power Consumption Wh = 260688
Power Consumption W = 13
andrewsayre commented 2 years ago

Please don't comment on old and closed issues. Open a new one, fill out the issue template, if you believe there's a bug not already addressed in the original issue.