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.89k stars 30.95k forks source link

SmartThings integration does not ingest Samsung ASHP info correctly #101265

Open ColinSainsbury opened 1 year ago

ColinSainsbury commented 1 year ago

The problem

I have a Samsung AE12BXYDEG/EU ASHP which is connected to SmartThings and from there to HA. Neither the official integration nor the HACS version (which I know is out of scope here) seem to know how to interface with it. Both show a single switch, which is on or off according to scheduling. However, under that should be 2 further switches for hot water and heating which then have separate schedules. I would also value capturing the energy imported and exported so that I can measure efficiency at least based on the internal Samsung reporting.

Home Energy Management is going to be a big part of the low carbon future so being able to integrate my solar PV and battery with my ASHP to boost hot water when export is occurring will benefit many.

What version of Home Assistant Core has the issue?

2023.9.3

What was the last working version of Home Assistant Core?

Never

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)

issue-triage-workflows[bot] commented 10 months 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.

ColinSainsbury commented 10 months ago

The current iteration of the integration is an improvement over that when I first raised the issue but it still presents data that is difficult to use and only one switch instead of the expected 2. The attached image shows the current output. Smartthings integration

Benjamin-ML commented 10 months ago

I have the exact same problem. The SmartThings platform sees the heat pump with two device IDs, but this integration cannot detect both devices.

ColinSainsbury commented 10 months ago

I see two separate devices 1 is the System Air Conditioner (Wi-Fi kit) which is the MIM-H04EN unit and the other is the Eco Heating System but only the EHS has sensors that report data.

elad-bar commented 10 months ago

Integration is working with main device only, found the issue and working on PR

ColinSainsbury commented 8 months ago

@elad-bar I see your pull request is stuck waiting for something - is there anything I can do (as a non-programmer) to help?

elad-bar commented 8 months ago

I hope i will get to it in the upcoming few weeks to create a custom integration with full support according to Samsung API as there is no progress here

wawyed commented 7 months ago

I hope i will get to it in the upcoming few weeks to create a custom integration with full support according to Samsung API as there is no progress here

That'd be trully amazing :D

Benjamin-ML commented 6 months ago

Is there anything I can do to help here? @elad-bar I am not a programmer, but perhaps I can do something.

ColinSainsbury commented 6 months ago

@elad-bar I see that @andrewsayre is no longer a code owner for the Smartthings integration. Are you in a position to reinvigorate the changes you were proposing for the new code owner?

elad-bar commented 6 months ago

Hi, i'm currently super overloaded (personal, work and maintaining custom components), Once pressure will be reduced a bit will try my best to contribute

wawyed commented 6 months ago

Just for everyone benefit I managed to get my ASHP working using the smartthings api, instead of this integration:

image

You will need the following:

https://github.com/jcwillox/hass-template-climate

and the bellow config:

configuration.yaml

rest: !include rest.yaml
rest_command: !include rest_command.yaml
climate: !include climate.yaml

rest.yaml

- scan_interval: 15
  resource: https://api.smartthings.com/v1/devices/XXX-XXX/status
  headers:
    Authorization: !secret smartthings_pat
  binary_sensor:
    - name: DHW status
      unique_id: "dhw_status"
      value_template: "{{ value_json.components.main.switch.switch.value }}"
    - name: Indoor status
      unique_id: "indoor_status"
      value_template: "{{ value_json.components.INDOOR.switch.switch.value }}"
  sensor:
    - name: DHW temperature target
      unique_id: "dhw_temperature_target"
      device_class: "temperature"
      state_class: "measurement"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.components.main.thermostatCoolingSetpoint.coolingSetpoint.value }}"
    - name: DHW temperature
      unique_id: "dhw_temperature"
      device_class: "temperature"
      state_class: "measurement"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.components.main.temperatureMeasurement.temperature.value }}"
    - name: Indoor temperature target
      unique_id: "indoor_temperature_target"
      device_class: "temperature"
      state_class: "measurement"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.components.INDOOR.thermostatCoolingSetpoint.coolingSetpoint.value }}"
    - name: Indoor temperature
      unique_id: "indoor_temperature"
      device_class: "temperature"
      state_class: "measurement"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.components.INDOOR.temperatureMeasurement.temperature.value }}"

rest_command.yaml

send_command_to_ashp:
  url: "https://api.smartthings.com/v1/devices/XXXX-XXXX/commands"
  method: post
  headers:
    Authorization: !secret smartthings_pat
  payload: '{
  "commands": [
    {
      "component": "{{ component }}",
      "capability": "{{ capability }}",
      "command": "{{ command }}",
      "arguments": {{ arguments }}
    }
  ]
}'
  content_type:  'application/json; charset=utf-8'

climate.yaml

- platform: climate_template
  unique_id: dhw_thermostat
  name: DHW Thermostat
  modes:
    - "heat"
    - "off"
  min_temp: 40
  max_temp: 70
  temp_step: 1
  current_temperature_template: "{{ states('sensor.dhw_temperature') }}"
  target_temperature_template: "{{ states('sensor.dhw_temperature_target') }}"
  hvac_action_template: >
    {% set mode = states('binary_sensor.dhw_status') %}
    {% set temperature = states('sensor.dhw_temperature') %}
    {% set target = states('sensor.dhw_temperature_target') %}
    {% set status = "heating" %}

    {% if mode == "off" %}
      {% set status = "off" %}
    {% elif temperature > target %}
      {% set status = "idle" %}
    {% endif %}

    {{ status }}
  hvac_mode_template: >
    {% set mode = states('binary_sensor.dhw_status') %}
    {% set status = "off" %}

    {% if mode in ("unavailable", "unknown") %}
      {% set status = states('climate.dhw_thermostat') %}
    {% elif mode == "on" %}
      {% set status = "heat" %}
    {% endif %}

    {{ status }}
  set_hvac_mode:
    - service: rest_command.send_command_to_ashp
      data:
        component: main
        capability: switch
        arguments: "[]"
        command: >
          {% set mode = hvac_mode %}
          {% set status ="off" %}

          {% if mode == "heat" %}
            {% set status = "on" %}
          {% endif %}

          {{ status }}
  set_temperature:
    - service: rest_command.send_command_to_ashp
      data:
        component: main
        capability: thermostatCoolingSetpoint
        command: setCoolingSetpoint
        arguments: "[{{ temperature }}]"
- platform: climate_template
  unique_id: indoor_thermostat
  name: Indoor Thermostat
  modes:
    - "heat"
    - "off"
  min_temp: 16
  max_temp: 30
  temp_step: 1
  current_temperature_template: "{{ states('sensor.indoor_temperature') }}"
  target_temperature_template: "{{ states('sensor.indoor_temperature_target') }}"
  hvac_action_template: >
    {% set mode = states('binary_sensor.indoor_status') %}
    {% set temperature = states('sensor.indoor_temperature') %}
    {% set target = states('sensor.indoor_temperature_target') %}
    {% set status = "heating" %}

    {% if mode == "off" %}
      {% set status = "off" %}
    {% elif temperature > target %}
      {% set status = "idle" %}
    {% endif %}

    {{ status }}
  hvac_mode_template: >
    {% set mode = states('binary_sensor.indoor_status') %}
    {% set status = "off" %}

    {% if mode in ("unavailable", "unknown") %}
      {% set status = states('climate.indoor_thermostat') %}
    {% elif mode == "on" %}
      {% set status = "heat" %}
    {% endif %}

    {{ status }}
  set_hvac_mode:
    - service: rest_command.send_command_to_ashp
      data:
        component: INDOOR
        capability: switch
        arguments: "[]"
        command: >
          {% set mode = hvac_mode %}
          {% set status = "off" %}

          {% if mode == "heat" %}
            {% set status = "on" %}
          {% endif %}

          {{ status }}
  set_temperature:
    - service: rest_command.send_command_to_ashp
      data:
        component: INDOOR
        capability: thermostatCoolingSetpoint
        command: setCoolingSetpoint
        arguments: "[{{ temperature }}]"

secrets.yaml


# Use this file to store secrets like usernames and passwords.
# Learn more at https://www.home-assistant.io/docs/configuration/secrets/
smartthings_pat: Bearer xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
ColinSainsbury commented 6 months ago

@wawyed I have added the above but the thermostats stubbornly stay at 21C (both) even if I try to adjust the values in rest.yaml. I have got to the edge of my comfort envelope in trying things but bigger brains than mine might see from the attached which values I need to use. diagnostic.json This was dumped using @elad-bar 's Dynamic Smartthings tool. The temperatures were 27.6C Indoor and 44.6C DHW at the time of dumping the info if that helps.

wawyed commented 6 months ago

@wawyed I have added the above but the thermostats stubbornly stay at 21C (both) even if I try to adjust the values in rest.yaml. I have got to the edge of my comfort envelope in trying things but bigger brains than mine might see from the attached which values I need to use. diagnostic.json This was dumped using @elad-bar 's Dynamic Smartthings tool. The temperatures were 27.6C Indoor and 44.6C DHW at the time of dumping the info if that helps.

Do you have any errors in the logs? Are the sensors reporting correctly in the entities tab in HA? (search for rest)

Also make sure you replaced XXX-XXX with the correct device id of your heatpump and the secret is setup correcltly smartthings_pat in the secrets.yaml

ColinSainsbury commented 6 months ago

Logger: homeassistant.components.rest_command Source: components/rest_command/init.py:158 integration: RESTful Command (documentation, issues) First occurred: 18:38:34 (2 occurrences) Last logged: 18:38:34

Error. Url: https://api.smartthings.com/v1/devices/Device_ID/commands. Status code 401. Payload: b'{ "commands": [ { "component": "INDOOR", "capability": "switch", "command": "off", "arguments": [] } ] }' Error. Url: https://api.smartthings.com/v1/devices/Device_ID/commands. Status code 401. Payload: b'{ "commands": [ { "component": "main", "capability": "switch", "command": "off", "arguments": [] } ] }'

Device_ID has been substituted for the real DeviceID.

wawyed commented 6 months ago

Logger: homeassistant.components.rest_command Source: components/rest_command/init.py:158 integration: RESTful Command (documentation, issues) First occurred: 18:38:34 (2 occurrences) Last logged: 18:38:34

Error. Url: https://api.smartthings.com/v1/devices/Device_ID/commands. Status code 401. Payload: b'{ "commands": [ { "component": "INDOOR", "capability": "switch", "command": "off", "arguments": [] } ] }' Error. Url: https://api.smartthings.com/v1/devices/Device_ID/commands. Status code 401. Payload: b'{ "commands": [ { "component": "main", "capability": "switch", "command": "off", "arguments": [] } ] }'

Device_ID has been substituted for the real DeviceID.

Looks like you haven't put the PAT in the secrets.xml ? You can generate it here https://account.smartthings.com/tokens and put it as so:

smartthings_pat: Bearer xxxxx-xxxx-xxxx-xxxx-xxxxxxxx
ColinSainsbury commented 6 months ago

Thanks - initially I missed replacing the XXX with the Device_ID. Then I missed including the word Bearer in the secrets.yaml Really appreciate all of your help. Next challenge is to start retrieving the data to calculate CoP and SCoP.

wawyed commented 6 months ago

Thanks - initially I missed replacing the XXX with the Device_ID. Then I missed including the word Bearer in the secrets.yaml Really appreciate all of your help. Next challenge is to start retrieving the data to calculate CoP and SCoP.

Do you have https://docs.openenergymonitor.org/applications/heatpump.html installed?

ColinSainsbury commented 6 months ago

No, I was hoping to do some basic monitoring based on Energy Output/Energy Input - I can see that main.powerConsumptionReport.powerConsumption includes a number of values although some of them are a bit of a mystery (powerEnergy for instance) I keep chipping away at the challenge. Worst case I go old school and touch the controller and use pen and paper.

Benjamin-ML commented 6 months ago

@wawyed Thanks for sharing your solution! I managed to integrate it. Super cool.

@ColinSainsbury I'm also looking for more technical data of Samsung heat pump. I might go for Modbus solution later this year. I need to install a Samsung Modbus board on the external unit and a Modbus to LAN device.

Just for everyone benefit I managed to get my ASHP working using the smartthings api, instead of this integration:

image

ColinSainsbury commented 6 months ago

I have the MIM-B19N [https://midsummerwholesale.co.uk/buy/samsung-heat-pumps/Samsung-modbus-MIM-B19] in my ASHP as I have a Homely Energy [https://midsummerwholesale.co.uk/buy/homely/homely-smart-controller-V3] managing it but you can only have one controller. I haven't been brave enough to look at Modbus to LAN yet.

ColinSainsbury commented 6 months ago

Please be careful. The Indoor thermostat temperature is reading the temperature of my airing cupboard because the controller is on the tank and I have not added a remote temperature sensor. Also adjusting the temperature of the Indoor thermostat will modify the FLOW temperature of the water heating the radiators/UFH not adjust the room temperature directly. This is not something you want to be doing normally.

I have a Homely controller doing all of the room and hot water control and scheduling for me because it is smart enough to pull in the Octopus Agile tariff data to use the cheapest slots. I am therefore using the data from Smartthings to monitor only. Although, I would like to automate a boost when the solar PV is banging ;-)

wawyed commented 6 months ago

Please be careful. The Indoor thermostat temperature is reading the temperature of my airing cupboard because the controller is on the tank and I have not added a remote temperature sensor. Also adjusting the temperature of the Indoor thermostat will modify the FLOW temperature of the water heating the radiators/UFH not adjust the room temperature directly. This is not something you want to be doing normally.

I have a Homely controller doing all of the room and hot water control and scheduling for me because it is smart enough to pull in the Octopus Agile tariff data to use the cheapest slots. I am therefore using the data from Smartthings to monitor only. Although, I would like to automate a boost when the solar PV is banging ;-)

I'm using my wired controller as my thermostat so in my case I adjust the room temperature not the flow temperature. You should be using water law anyway though which should only allow you to change the offset in that case.

ColinSainsbury commented 6 months ago

In my case water law is disabled because the Homely is talking MODBUS and directly managing the ASHP to fine tune it. They have some smart stuff going on. I was putting the warning out there for those who may not realise what is going on.

wawyed commented 6 months ago

In my case water law is disabled because the Homely is talking MODBUS and directly managing the ASHP to fine tune it. They have some smart stuff going on. I was putting the warning out there for those who may not realise what is going on.

oh yeah if you use homely, not sure it makes sense to use home assistant to control thermostats as they are going to conflict with each other

ePiccio commented 6 months ago

Ciao all, question: will the above allow us to read also the external temperature? my Samsung heatpump has an external sensor built into the outoor unit to read the temp which is then used for the water-law parametrization. that is the key sensor i miss to display in ha

wawyed commented 6 months ago

Ciao all, question: will the above allow us to read also the external temperature? my Samsung heatpump has an external sensor built into the outoor unit to read the temp which is then used for the water-law parametrization. that is the key sensor i miss to display in ha

Unfortunately not, that doesn't seem to be exposed in the smartthings api :(. You'll need the modbus device for that.

ColinSainsbury commented 4 months ago

@wawyed I am trying to create an automation to cause the ASHP to boost the hot water temp to 55C when we are exporting significant amounts of solar generation (I have a Myenergi Eddi but want the efficiency of the ASHP). I have tried the following based on the climate.yaml instructions you provided but I am not making any headway. Can you guide me please?

alias: ASHP DHW Boost description: "" trigger: [] condition: [] action:

I have not included the trigger automation because I am trying to run it from a button until I figure out the right approach.

ColinSainsbury commented 4 months ago

Paying back to the community in my own limited way. I finally got the automation working:

alias: ASHP DHW Boost timed
description: ""
trigger:
  - platform: time
    at: "20:50:00"
action:
  - service: climate.set_temperature
    target:
      entity_id: climate.dhw_thermostat
    data:
      temperature: 55
      hvac_mode: heat

I used timed here but intend to trigger off Solar PV export once I have exported more than the value of electricity imported including the standing charge. I also have this on a button for a manual override.

show_name: true
show_icon: true
type: button
name: DHW Boost
icon: mdi:heat-pump
entity: climate.dhw_thermostat
tap_action:
  action: call-service
  service: climate.set_temperature
  target:
    entity_id: climate.dhw_thermostat
  data:
    temperature: 55
    hvac_mode: heat
vanwalsum commented 2 months ago

I recommended a friend Home Assistant to control his Samsung Heatpump with the 04 wifi kit. But Home Assistant refuses to work with it. Can someone help me with it? Token is set, I can see that Home Assistant is authorized in SmartThings, the webhook is set by Nabu Casa. I don't know it anymore and don't want to buy him a Homey.

Scherm­afbeelding 2024-08-28 om 22 36 10 Scherm­afbeelding 2024-08-28 om 22 36 02 Scherm­afbeelding 2024-08-28 om 22 35 45
wawyed commented 2 months ago

I recommended a friend Home Assistant to control his Samsung Heatpump with the 04 wifi kit. But Home Assistant refuses to work with it. Can someone help me with it? Token is set, I can see that Home Assistant is authorized in SmartThings, the webhook is set by Nabu Casa. I don't know it anymore and don't want to buy him a Homey. Scherm­afbeelding 2024-08-28 om 22 36 10 Scherm­afbeelding 2024-08-28 om 22 36 02 Scherm­afbeelding 2024-08-28 om 22 35 45

Maybe you could try to use my approach instead?

vanwalsum commented 2 months ago

I recommended a friend Home Assistant to control his Samsung Heatpump with the 04 wifi kit. But Home Assistant refuses to work with it. Can someone help me with it? Token is set, I can see that Home Assistant is authorized in SmartThings, the webhook is set by Nabu Casa. I don't know it anymore and don't want to buy him a Homey. Scherm­afbeelding 2024-08-28 om 22 36 10 Scherm­afbeelding 2024-08-28 om 22 36 02 Scherm­afbeelding 2024-08-28 om 22 35 45

Maybe you could try to use my approach instead?

i tried, but i can't get any data. I'm out of thoughts what it could be... appreciate any help.

2 1

I'm just confused. With the SmartThings app, i assume you need to see some value's of the sensors working or the switch. It looks like the API is not communicating at all. Webhook set, secret set, accepted on the smartthings login, it sees the devices...

Maybe someone can look with anydesk or teamviewer... even would like to pay for it if someone gets it fixen.

ColinSainsbury commented 2 months ago

I have a Homely and without wishing to be unkind, if you are struggling getting this working, it might be an easier and more foolproof route in the long run. Especially if your friend needs you to be his IT support.

I have used the above path and the branch of the Climate_IP https://github.com/atxbyea/samsungrac to connect my Home Assistant to my Samsung HTQ Mono via REST. Both routes are essentially the same but you will need two things: The Device ID of the heat pump which you can get from https://my.smartthings.com/advanced Select Devices from the left panel and you will see a Device ID associated with the heat pump. You will need this to substitute for the XXXX in the rest_command.yaml

You will also need the PAT you used to hook SmartThings to HomeAssistant. This goes into secrets.yaml like this

smartthings_pat: Bearer YYYYYYYYYYYY replacing the YYYYs with your PAT

I missed the word Bearer initially and that prevented the data flow.

I hope this helps

vanwalsum commented 2 months ago

Okay, i have a small update. The only thing what works is when i set the "indoor thermostat" to heat, the heatpump turns on! Fantastic, that means there is some communication. Device off don't work. Here we have some commands an attributes from the smartthings integration. I think i need to check why only the heat command works on the indoor thermostat and all the others and information are not working....

Schermafbeelding 2024-08-29 150330 Attributes Commands

vanwalsum commented 2 months ago

Edit: Am i supposed to put the word Brearer in front of any token? I added "Brearer" in the rest.yaml and now i got temps! Happy!!

Schermafbeelding 2024-08-29 152031 Schermafbeelding 2024-08-29 152135

wawyed commented 2 months ago

Edit: Am i supposed to put the word Brearer in front of any token? I added "Brearer" in the rest.yaml and now i got temps! Happy!!

Schermafbeelding 2024-08-29 152031 Schermafbeelding 2024-08-29 152135

That's correct

vanwalsum commented 2 months ago

So happy now! The only strange thing is that my indoor thermostat commands my heatpump (water), en the DHW Thermostat does not work. I hide the last one now.

ColinSainsbury commented 1 month ago

@wawyed I am trying to pull the daily energy consumption into a sensor. The data point is stored in main.powerConsumptionReport.powerConsumption which holds an array of data. The key value is "energy" with the value stored in Wh as an increasing total.

The other potentially less useful value in that array is the "power" value which I believe is current power draw in W.

image

Is there a way to do this? It is last reason I need the Smartthings Integration which is proving unreliable and seemingly unsupported these days.

wawyed commented 1 month ago

@wawyed I am trying to pull the daily energy consumption into a sensor. The data point is stored in main.powerConsumptionReport.powerConsumption which holds an array of data. The key value is "energy" with the value stored in Wh as an increasing total.

The other potentially less useful value in that array is the "power" value which I believe is current power draw in W.

image

Is there a way to do this? It is last reason I need the Smartthings Integration which is proving unreliable and seemingly unsupported these days.

Yes, that should be possible. Just create a sensor to read that data using the examples above

ColinSainsbury commented 1 month ago

For anyone finding this via search, the sensor looks like this: `- name: ASHP Daily Energy

  unique_id: "ashp_daily_energy" 

  state_class: "total" 

  device_class: "energy" 

  unit_of_measurement: "Wh" 

  value_template: "{{ value_json.components.main.powerConsumptionReport.powerConsumption.value.energy }}" 

` The sensor retrieves data in Wh so you will need a template sensor to divide it by 1000 to provide a kWh sensor that can then be used in the Energy tab for tracking purposes.