elupus / hass_nibe

Home Assistant Nibe Uplink Integration
184 stars 54 forks source link

set_thermostat service "could not be called" #26

Closed bohtho closed 5 years ago

bohtho commented 5 years ago

Just pulled the latest version of this integration, and tried the new set_thermostat service. Tried to call it with the JSON (xxxxx replaced with my system):

{ "system": "xxxxx", "id": "1", "name": "stue", "temperature": "21.2", "target_temperature": "18.0", "valve_position": "0" }

Both from the Node-Red Homeassistant-websocket "call service" node, AND from the developer tool to call services in HA. From Node-Red all I could see was "API error from Home Assistant: Invalid Format" and in HA the developer tool just said it couldn't call the service.

I tried to send the numbers as floats and integers instead of strings but no change. Any idea ?

Also: The entities for S1 Room and S1 Supply seem to have vanished(?). The States UI now has a card that says "Invalid config":

The following components and platforms could not be set up:

nibe.climate

Please check your config.

The log shows a maybe relevant entry as well:

2019-03-12 12:27:32 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.nibe.climate. Make sure all dependencies are installed Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/loader.py", line 147, in _load_file module = importlib.import_module(path) File "/home/homeassistant/.pyenv/versions/3.6.3/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/home/homeassistant/.homeassistant/custom_components/nibe/climate.py", line 10, in from homeassistant.components.climate.const import (ATTR_OPERATION_MODE, ImportError: cannot import name 'STATE_AUTO' 2019-03-12 12:27:32 ERROR (MainThread) [homeassistant.loader] Unable to find platform nibe 2019-03-12 12:27:32 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform nibe.climate: Platform not found.

bohtho commented 5 years ago

Any comment? I made this new issue after you implemented the new thermostat service and I had tested that version, as per your wish in the other “smarthouse mode” issue.

bohtho commented 5 years ago

Anyhow, I happened to read up on breaking changes in HA for developers of custom components just now, and updated HA. The errors now seem to be gone. Shall now test the service (which I see from a commit needed the missing "systems" part).

elupus commented 5 years ago

Yes sorry. Though it would be more obvious why I closed the issue. Anyway, it was a documentation issue. The error above was a issue with 0.89 home assistant. Seems I didn't even read that long. 0.90 should be fine.

bohtho commented 5 years ago

Updated and still can't make it work. Sorry.

I get this in the log entry for the set_thermostat service call:

400, message='{
  "httpStatusCode": 400,
  "errorCode": 1,
  "timestamp": "2019-03-15T09:21:23.9567831Z",
  "details": [],
  "data": null
}'
Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/home/homeassistant/.homeassistant/custom_components/nibe/services.py", line 52, in set_thermostat
    data)
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/nibeuplink/__init__.py", line 602, in post_smarthome_thermostats
    headers=headers)
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/nibeuplink/__init__.py", line 361, in post
    **kwargs
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/nibeuplink/__init__.py", line 378, in _request
    await raise_for_status(response)
  File "/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/nibeuplink/__init__.py", line 182, in raise_for_status
    headers=response.headers)
aiohttp.client_exceptions.ClientResponseError: 400, message='{
  "httpStatusCode": 400,
  "errorCode": 1,
  "timestamp": "2019-03-15T09:21:23.9567831Z",
  "details": [],
  "data": null
}'

This was the JSON I sent in the data (just my system number instead of xxxxx):

{
    "system": xxxxx,
    "id": 1,
    "name": "test room",
    "systems": [1],
    "temperature": 20,
    "target_temperature": 21,
    "valve_position": 15
}
elupus commented 5 years ago

Hmm it's being rejected. Weird. What if you don't specify a valve position?

bohtho commented 5 years ago

Its the same without valve_position. And the same with a new higher id every time.

elupus commented 5 years ago

But you can use the thermostat entities?

elupus commented 5 years ago

Wait, you selected the write access checkbox when you set up the integration?

bohtho commented 5 years ago

How can I check that ?

I did earlier when the component used to be configured in the configuration.yaml. And then I upgraded the component where system id etc was set afterwards in HA integrations. And I can still use the hot_water_boost switch. Wouldn’t that require write access ?

elupus commented 5 years ago

Hot water boost does require write, so you probably have it then.

Termostat is not climate, it's smart thermostats. Look at docs about how to add a smart thermostat (you need a temp senor or a dummy input_number entity) for current temp.

bohtho commented 5 years ago

No, I'm calling your "nibe.set_thermostat" service directly with the data in a json. Its example data includes valves etc. It’s supposed to be the smart home thermostats in Uplink.

Anyone else getting it to work? Remember, you don’t have to have “Smart home” under your NIBE settings activated to test the smart home thermostats in Uplink. IFTTT sends smart home thermostat data to Uplink->Smart home->Thermostats anyway.

elupus commented 5 years ago

Well I asked you to try with the termostat function instead of the service.

Anyway I think it is fixed. Forgot to scale temperatures.