Closed christian-ek closed 3 years ago
What model do you have? The best would be to make full rawscan, eg like this: https://github.com/moustic999/bosch-thermostat-http-client-python/blob/dev/rawscan.py and provide it here. It all depends of operationMode which you are currently running.
Okay, I put it on pastebin: https://pastebin.com/H4pRrcui
So you have RC300. Lib is already compatible with it.
Just use set_temperature
function from dhw object and you good.
How do i get the dhw object? I'm kind of a noob with this.
Also how do i get the "/system/healthStatus" ? And also how do i set the charge to "start"? "/dhwCircuits/dhw1/charge" ?
healthStatus
would be sensor. This will be easier available in next version.
For dhw
we are currently support set_operation_mode and set_temperature as operation_mode should determine automatically if dhw need to be charged.
To get dhw object go to example.py and rewrite gateway part to something like:
gateway = bosch.Gateway(session,
host=data[0],
access_key=data[1],
password=data[2])
await gateway.check_connection()
await gateway.initialize_circuits(DHW)
dhws = gateway.dhw_circuits
dhw = dhws[0]
await dhw.update()
print(dhw.target_temperature)
with new version to get sensor:
gateway = bosch.Gateway(session,
host=data[0],
access_key=data[1],
password=data[2])
await gateway.check_connection()
await gateway.initialize_sensors(["healthStatus"])
healthSensor = data[GATEWAY].sensors
print(healthSensor.get_all_properties())
I tried it today but it failed.
async def main():
"""
Provide data_file.txt with ip, access_key, password and check
if you can retrieve data from your thermostat.
"""
async with aiohttp.ClientSession() as session:
data_file = open("data_file.txt", "r")
data = data_file.read().splitlines()
gateway = bosch.Gateway(session,
host=data[0],
access_key=data[1],
password=data[2])
await gateway.check_connection()
await gateway.initialize_sensors(["healthStatus"])
healthSensor = data[GATEWAY].sensors
print(healthSensor.get_all_properties())
await session.close()
asyncio.get_event_loop().run_until_complete(main())
Traceback (most recent call last):
File "example.py", line 35, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "example.py", line 30, in main
await gateway.initialize_sensors(["healthStatus"])
TypeError: object dict_values can't be used in 'await' expression
Check this out:
async def main():
"""
Provide data_file.txt with ip, access_key, password and check
if you can retrieve data from your thermostat.
"""
async with aiohttp.ClientSession() as session:
data_file = open("data_file.txt", "r")
data = data_file.read().splitlines()
gateway = bosch.Gateway(session,
host=data[0],
access_key=data[1],
password=data[2])
await gateway.check_connection()
sensors = gateway.initialize_sensors(["healthStatus"])
healthSensor = data[GATEWAY].sensors[0]
print(await healthSensor.get_all_properties())
await session.close()
asyncio.get_event_loop().run_until_complete(main())
What should GATEWAY be set to?
NameError: name 'GATEWAY' is not defined
I'll create a file in examples with sensors and get back to you. Copy/paste is troublemaker...
install new version of lib and just run bosch_examples sensors --help
and test it.
Later check out file for source code: https://github.com/moustic999/bosch-thermostat-http-client-python/blob/dev/bosch_thermostat_http/bosch_examples.py
Thank you! Is there a way to set a value aswell? I would like to set "/dhwCircuits/dhw1/charge" to "start"
Yes. you can.
You need to use put
function of gateway.
Here is how I am setting temp:
https://github.com/moustic999/bosch-thermostat-http-client-python/blob/5c6d6326539515a39011b04d9a7daba46c1718e4/bosch_thermostat_http/circuit.py#L268-L270
to set charge you need something like this:
await gateway.put("/dhwCircuits/dhw1/charge", "start")
I ran into trouble here:
~> bosch_examples sensors --sensor outdoor_t1 --ip xxx --token xxx --password xxx
INFO:bosch_thermostat_http.bosch_examples:Successfully connected to gateway. Found UUID: 458350086
Traceback (most recent call last):
File "/home/pi/.local/bin/bosch_examples", line 10, in <module>
sys.exit(cli())
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 29, in wrapper
return asyncio.run(f(*args, **kwargs))
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 67, in sensors
print(sensor_obj.name, ":", sensor_obj.get_all_properties())
TypeError: 'dict_keys' object is not callable
So you have RC300. Lib is already compatible with it. Just use
set_temperature
function from dhw object and you good.
How can you see model from rawscan? Here is mine: https://pastebin.com/YyvCDF6y
Line 1900. You have RC300. Please open new issue if you have problems. For problems regarding working with HomeAssistant go to my repo and fill issue there https://github.com/pszafer/home-assistant-bosch-custom-component
@christian-ek method you are trying to call is not callable, it means delete ()
@pszafer but I'm only trying to run bosch_examples using a specific sensor. Didn't change anything in your code
Sorry, I will fix it ASAP.
Should be fixed in v0.6.2.
Yes that is working now.
I'm trying out 0.7.2 now and getting another exception.
$ bosch_examples dhw --ip {IP} --token {token} --password {pwd} -t --op_modes --setpoints -m
INFO:bosch_thermostat_http.bosch_examples:Successfully connected to gateway. Found UUID: 458350086
Target temp of dhw1 is: 50.0
Traceback (most recent call last):
File "/home/pi/.local/bin/bosch_examples", line 10, in <module>
sys.exit(cli())
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 29, in wrapper
return asyncio.run(f(*args, **kwargs))
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 127, in dhw
await circuit_fetch(gateway, DHW, target_temp, op_mode, op_modes, setpoints)
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 142, in circuit_fetch
print(f"Operation mode of {circuit.name} is: {circuit.current_mode}")
AttributeError: 'Circuit' object has no attribute 'current_mode'
Same with HC
$ bosch_examples hc --ip {IP} --token {token} --password {pwd} -t --op_modes --setpoints -m
INFO:bosch_thermostat_http.bosch_examples:Successfully connected to gateway. Found UUID: 458350086
Target temp of hc1 is: 22.0
Traceback (most recent call last):
File "/home/pi/.local/bin/bosch_examples", line 10, in <module>
sys.exit(cli())
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 29, in wrapper
return asyncio.run(f(*args, **kwargs))
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 97, in hc
await circuit_fetch(gateway, HC, target_temp, op_mode, op_modes, setpoints)
File "/home/pi/.local/lib/python3.7/site-packages/bosch_thermostat_http/bosch_examples.py", line 142, in circuit_fetch
print(f"Operation mode of {circuit.name} is: {circuit.current_mode}")
AttributeError: 'Circuit' object has no attribute 'current_mode'
bosch_cli is working pretty well right now. If you have any issues or questions ask in current repository.
Hi, I am using Homey as my home automation hub. I want to use your client to create a rest api with some features that i can call from my homey. I have tried your examples and am wondering if you could help me out with how i easiest perform these operations using your client?
Get value from here:
and here:
Also how i can write start to "/dhwCircuits/dhw1/charge" which i think would start the hot water charge? :
Thank you for creating the client, I have been looking a long time for something like this. I am using IVT which i guess is bosch made here in Sweden.