WThermostatBeca icon indicating copy to clipboard operation
WThermostatBeca copied to clipboard

Thermostat model BHT 8000

Open grbasta opened this issue 4 years ago • 46 comments

Hello, in your opinion this firmware, can it be good for this model? bht8000

grbasta avatar Dec 10 '20 11:12 grbasta

Would be awesome if it will work!

Master-Rudi avatar Dec 10 '20 15:12 Master-Rudi

It surely works, as I've based my own firmware on codes found in this repository, I can even send weather infos to it ;) WhatsApp Image 2021-01-13 at 10 37 11 AM

nwaelti avatar Jan 13 '21 09:01 nwaelti

It surely works, as I've based my own firmware on codes found in this repository, I can even send weather infos to it ;) WhatsApp Image 2021-01-13 at 10 37 11 AM

Hello and so what firmware can we use, to put it locally? Thanks

grbasta avatar Jan 14 '21 09:01 grbasta

You can use this [ fashberg ] firmware on it... https://github.com/fashberg/WThermostatBeca/releases/tag/v1.18-fas It will work just fine

nwaelti avatar Jan 14 '21 09:01 nwaelti

You can use this [ fashberg ] firmware on it... https://github.com/fashberg/WThermostatBeca/releases/tag/v1.18-fas It will work just fine

Hello, but do you need to flash with cables or with tuya-convert? I tried tuya-convert but it doesn't work. Do you have the right procedure? Thanks

grbasta avatar Jan 16 '21 10:01 grbasta

Tuya convert never worked for me... I unsoldered the chip (TYWES3) and flashed it outside of the thermostat with a flashing tool and resoldered it afterward in the thermostat.

nwaelti avatar Jan 16 '21 12:01 nwaelti

Tuya convert never worked for me... I unsoldered the chip (TYWES3) and flashed it outside of the thermostat with a flashing tool and resoldered it afterward in the thermostat.

Hello sorry if I always ask you, I flashed the firmware you indicated, but unfortunately it does not work on home assistant, temperatures and states, are we sure it works for the bht 8000? I could try what you have, maybe it works. Thanks

image

grbasta avatar Jan 16 '21 17:01 grbasta

I am also not using HASS, I can only tell you that the code used in this firmware works with the beca serie 8000 well... Are you able to connect to it with your webbrowser and directly with MQTT ? You will not be able to use my firmware, I'm not using something that is well known, I'm developed my own smart home system based on MQTT and some of my config is hard coded into the firmware

nwaelti avatar Jan 17 '21 14:01 nwaelti

I am also not using HASS, I can only tell you that the code used in this firmware works with the beca serie 8000 well... Are you able to connect to it with your webbrowser and directly with MQTT ? You will not be able to use my firmware, I'm not using something that is well known, I'm developed my own smart home system based on MQTT and some of my config is hard coded into the firmware

Good evening what I wanted to report is that the same firmware, installed on BHT-002-GCLW (Water / Gas Boiler), behaves very well with Home Assistant, while installed on the BHT 8000 does not have the same effect, i.e. it does not expose the set temperature and that measured and the on and off commands do not work. While if you want to use it from its touch it works well. It would seem that MQTT does not interact, yet comparing them the settings are identical, obviously the name and related topic change. Greetings

grbasta avatar Jan 17 '21 18:01 grbasta

Maybe you could try to change this function image in WBecaDevice.h to return always true and recompile you own version... Did you manage to access the website of the thermostat? (http://IP/things) to check if it answers there ? MQTT topics are not changing as they are managed by this firmware and not he MCU.

nwaelti avatar Jan 18 '21 13:01 nwaelti

Magari potresti provare a cambiare questa funzione in WBecaDevice.h per restituire sempre true e ricompilare la tua versione ... Sei riuscito ad accedere al sito web del termostato? ( http: // IP / cose ) per verificare se risponde lì? Gli argomenti MQTT non cambiano poiché sono gestiti da questo firmware e non dall'MCU. Immagine

Hi, this is what i see if i go from ip / things browser: [{"name":"Termostato-PT_Thermostat","@context":"https://iot.mozilla.org/schemas","title":"Termostato-PT_Thermostat","@type":["Thermostat"],"properties":{"switchBackToAuto":{"title":"switch Back from Manual to Auto at next Schedule","type":"boolean","links":[{"href":"/things/thermostat/properties/switchBackToAuto"}]},"temperature":{"title":"Actual","type":"number","readOnly":true,"unit":"celsius","@type":"TemperatureProperty","links":[{"href":"/things/thermostat/properties/temperature"}]},"targetTemperature":{"title":"Target","type":"number","unit":"celsius","multipleOf":0.50,"@type":"TargetTemperatureProperty","links":[{"href":"/things/thermostat/properties/targetTemperature"}]},"deviceOn":{"title":"Power","type":"boolean","links":[{"href":"/things/thermostat/properties/deviceOn"}]},"schedulesMode":{"title":"Schedules","type":"string","enum":["off","auto"],"@type":"ThermostatSchedulesModeProperty","links":[{"href":"/things/thermostat/properties/schedulesMode"}]},"ecoMode":{"title":"Eco","type":"boolean","links":[{"href":"/things/thermostat/properties/ecoMode"}]},"locked":{"title":"Lock","type":"boolean","links":[{"href":"/things/thermostat/properties/locked"}]},"mode":{"title":"Mode","type":"string","enum":["off","auto","heat"],"@type":"ThermostatModeProperty","links":[{"href":"/things/thermostat/properties/mode"}]},"action":{"title":"Action","type":"string","readOnly":true,"enum":["off","heating","idle"],"@type":"ThermostatActionProperty","links":[{"href":"/things/thermostat/properties/action"}]},"state":{"title":"State","type":"string","readOnly":true,"enum":["off","heating","cooling","fan"],"@type":"HeatingCoolingProperty","links":[{"href":"/things/thermostat/properties/state"}]},"mcuId":{"title":"mcuId","type":"string","readOnly":true,"links":[{"href":"/things/thermostat/properties/mcuId"}]}}}]

grbasta avatar Jan 18 '21 17:01 grbasta

Io non sono securo, ma penso chè dovrebe provare da collegarti sul link chè se vede nel schema: image Ai provato di recompilare il firmware con la modifica nella funziona hasDeviceWithHassAutodiscoverSupport() ?

nwaelti avatar Jan 19 '21 08:01 nwaelti

Io non sono securo, ma penso chè dovrebe provare da collegarti sul link chè se vede nel schema: image Ai provato di recompilare il firmware con la modifica nella funziona hasDeviceWithHassAutodiscoverSupport() ?

Good morning, then maybe we didn't understand each other, I have the same firmware, I have installed it both on the Moes and on the BHT 8000 as you can see from the attached photo, the only difference is that for the moes I used the tuya at the time -convert and on the BHT 8000 with cables soldered on the TYWES3. Except that for the Moes on Home Assistant no problem, while the BHT 8000 does not detect the status and temperatures, but accepts the commands. Accessing from the web: on the MOES and it works fine. http://192.168.2.18/things/thermostat/properties I read this: {"idx": "Thermostat-P1", "ip": "192.168.2.18", "firmware": "1.18-fas", "switchBackToAuto": true, "temperature": 22.50, "targetTemperature": 22.00, " deviceOn ": true," schedulesMode ":" off "," ecoMode ": false," locked ": false," mode ":" heat "," action ":" idle "," state ":" off "," mcuId ":" IAYz2WK1th0cMLmL1.0.0 "} Accessing from the web: on the BHT 8000 and it works badly. http://192.168.2.16/things/thermostat/properties I read this: {"idx": "Thermostat-PT", "ip": "192.168.2.16", "firmware": "1.18-fas", "switchBackToAuto": true, "temperature": 23.00, "targetTemperature": 22.00, " deviceOn ": true," schedulesMode ":" off "," ecoMode ": false," locked ": false," mode ":" heat "," action ":" idle "," state ":" off "," mcuId ":" {"p": "IAYz2WK1th0cMLmL", "v": "1.0"}

I noticed that on the second result after mcuID there is a {too many, so I think that's what messes up the reading on Mqtt. How can this be solved? I don't know what software you can use. Thanks

image

grbasta avatar Jan 19 '21 09:01 grbasta

@grbasta I'm in the same boat, have 2 of these thermostats... I have tweaked a little bit the code for this model and recompiled from source, finally got it working properly. Issue was incorrect/new output JSON formatting as you saw in ProductID: notice: Product ID Answer from MCU (commandLength: 42) notice: MCU: productId;55 aa 03 01 00 2a 7b 22 70 22 3a 22 49 41 59 7a 32 57 4b 31 74 68 30 63 4d 4c 6d 4c 22 2c 22 76 22 3a 22 31 2e 30 2e 30 22 2c 22 6d 22 3a 30 7d notice: Product ID: '{"p":"IAYz2WK1th0cMLmL","v":"1.0.0","m":0}'

So I have made "quick&dirty" fix and seems all works fine:

else if (receivedCommand[3] == 0x01) { // Product ID Answer // 55 aa 01 01 00 15 // HE AD VR CM LENGT network->log()->notice(F("Product ID Answer from MCU (commandLength: %d)"), commandLength); logIncomingCommand("productId" , LOG_LEVEL_NOTICE); knownCommand=true; if (commandLength>=5){ unsigned int len=0; //len = ((byte)receivedCommand[4] <<8) + (byte)receivedCommand[5]; // original line len = 16; // badger707 // char buf[len+1]; // original line char buf[17]; // badger707 for (unsigned int i=0;i<len;i++){ //buf[i]=receivedCommand[6+i]; // original line buf[i]=receivedCommand[12+i]; // badger707 } buf[len]=0; this->mcuId->setString(buf); if (mcuInitializeState==2) mcuInitializeState++; network->log()->notice(F("Product ID: '%s'"), buf); } }

I know thats not ideal way of doing this but it works, and lets hope @fashberg will twist this and will make integration for next release.

Here is view from http://device_ip/things/thermostat/properties badger707_BHT8000GCLW_v0 1a

You can grab compiled firmware binary file for BHT-8000 from here https://github.com/badger707/WThermostatBeca/tree/master/BHT-8000GCLW All credits belongs to original authors, I just done small tweak to get it working for this model.

In thermostat config web page you'll still see old thermostats listed in drop-down list... Have not updated these, but have them selected as BHT-002-GBLW and works just fine

Edit: for clarity -- above mentioned tweak is a fix for HASS integration (but correct me if I'm wrong).

badger707 avatar Feb 08 '21 22:02 badger707

@grbasta I'm in the same boat, have 2 of these thermostats... I have tweaked a little bit the code for this model and recompiled from source, finally got it working properly. Issue was incorrect/new output JSON formatting as you saw in ProductID: notice: Product ID Answer from MCU (commandLength: 42) notice: MCU: productId;55 aa 03 01 00 2a 7b 22 70 22 3a 22 49 41 59 7a 32 57 4b 31 74 68 30 63 4d 4c 6d 4c 22 2c 22 76 22 3a 22 31 2e 30 2e 30 22 2c 22 6d 22 3a 30 7d notice: Product ID: '{"p":"IAYz2WK1th0cMLmL","v":"1.0.0","m":0}'

So I have made "quick&dirty" fix and seems all works fine:

else if (receivedCommand[3] == 0x01) { // Product ID Answer // 55 aa 01 01 00 15 // HE AD VR CM LENGT network->log()->notice(F("Product ID Answer from MCU (commandLength: %d)"), commandLength); logIncomingCommand("productId" , LOG_LEVEL_NOTICE); knownCommand=true; if (commandLength>=5){ unsigned int len=0; //len = ((byte)receivedCommand[4] <<8) + (byte)receivedCommand[5]; // original line len = 16; // badger707 // char buf[len+1]; // original line char buf[17]; // badger707 for (unsigned int i=0;i<len;i++){ //buf[i]=receivedCommand[6+i]; // original line buf[i]=receivedCommand[12+i]; // badger707 } buf[len]=0; this->mcuId->setString(buf); if (mcuInitializeState==2) mcuInitializeState++; network->log()->notice(F("Product ID: '%s'"), buf); } }

I know thats not ideal way of doing this but it works, and lets hope @fashberg will twist this and will make integration for next release.

Here is view from http://device_ip/things/thermostat/properties badger707_BHT8000GCLW_v0 1a

You can grab compiled firmware binary file for BHT-8000 from here https://github.com/badger707/WThermostatBeca/tree/master/BHT-8000GCLW All credits belongs to original authors, I just done small tweak to get it working for this model.

In thermostat config web page you'll still see old thermostats listed in drop-down list... Have not updated these, but have them selected as BHT-002-GBLW and works just fine

Edit: for clarity -- above mentioned tweak is a fix for HASS integration (but correct me if I'm wrong).

Good morning in the meantime thank you, in fact it was not read well with mqtt by home assistant and therefore not manageable. When I learn to make the changes myself it will always be too late. I'll test it tonight. Greetings

grbasta avatar Feb 09 '21 06:02 grbasta

@grbasta I'm in the same boat, have 2 of these thermostats... I have tweaked a little bit the code for this model and recompiled from source, finally got it working properly. Issue was incorrect/new output JSON formatting as you saw in ProductID: notice: Product ID Answer from MCU (commandLength: 42) notice: MCU: productId;55 aa 03 01 00 2a 7b 22 70 22 3a 22 49 41 59 7a 32 57 4b 31 74 68 30 63 4d 4c 6d 4c 22 2c 22 76 22 3a 22 31 2e 30 2e 30 22 2c 22 6d 22 3a 30 7d notice: Product ID: '{"p":"IAYz2WK1th0cMLmL","v":"1.0.0","m":0}'

So I have made "quick&dirty" fix and seems all works fine:

else if (receivedCommand[3] == 0x01) { // Product ID Answer // 55 aa 01 01 00 15 // HE AD VR CM LENGT network->log()->notice(F("Product ID Answer from MCU (commandLength: %d)"), commandLength); logIncomingCommand("productId" , LOG_LEVEL_NOTICE); knownCommand=true; if (commandLength>=5){ unsigned int len=0; //len = ((byte)receivedCommand[4] <<8) + (byte)receivedCommand[5]; // original line len = 16; // badger707 // char buf[len+1]; // original line char buf[17]; // badger707 for (unsigned int i=0;i<len;i++){ //buf[i]=receivedCommand[6+i]; // original line buf[i]=receivedCommand[12+i]; // badger707 } buf[len]=0; this->mcuId->setString(buf); if (mcuInitializeState==2) mcuInitializeState++; network->log()->notice(F("Product ID: '%s'"), buf); } }

I know thats not ideal way of doing this but it works, and lets hope @fashberg will twist this and will make integration for next release.

Here is view from http://device_ip/things/thermostat/properties badger707_BHT8000GCLW_v0 1a

You can grab compiled firmware binary file for BHT-8000 from here https://github.com/badger707/WThermostatBeca/tree/master/BHT-8000GCLW All credits belongs to original authors, I just done small tweak to get it working for this model.

In thermostat config web page you'll still see old thermostats listed in drop-down list... Have not updated these, but have them selected as BHT-002-GBLW and works just fine

Edit: for clarity -- above mentioned tweak is a fix for HASS integration (but correct me if I'm wrong).

Hello now in the home assistant I see the temperature of the thermostat that I did not see before, but I don't see the climate entity, does it happen to you too?

grbasta avatar Feb 09 '21 17:02 grbasta

So my initial thoughts was that main issue in HA was about MCUID output format... It seems there is something else incorrect/wrong in payload or its formatting, and HA keeps throwing errors in logs.... I'll try to have a look, but I'm no expert in here...

badger707 avatar Feb 10 '21 12:02 badger707

Hi. It looks like temp_step has some trash in it.

"temp_step":"1� �",

Cheers, Mateusz

f3nix avatar Feb 10 '21 13:02 f3nix

So my initial thoughts was that main issue in HA was about MCUID output format... It seems there is something else incorrect/wrong in payload or its formatting, and HA keeps throwing errors in logs.... I'll try to have a look, but I'm no expert in here...

However for the moment I have inserted the mqtt platform in the configuration.yaml and I have solved this: climate:

  • platform: mqtt name: Thermostat-P1 send_if_off: false availability_topic: "home / Thermostat-P1 / tele / LWT" payload_available: Online payload_not_available: Offline action_topic: "home / Thermostat-P1 / stat / things / thermostat / properties" action_template: "{{value_json.action}}" mode_command_topic: "home / Thermostat-P1 / cmnd / things / thermostat / properties / mode" mode_state_topic: "home / Thermostat-P1 / stat / things / thermostat / properties" mode_state_template: "{{value_json.mode}}" away_mode_command_topic: "home / Thermostat-P1 / cmnd / things / thermostat / properties / ecoMode" away_mode_state_topic: "home / Thermostat-P1 / stat / things / thermostat / properties" away_mode_state_template: "{{value_json.ecoMode}}" temperature_command_topic: "home / Thermostat-P1 / cmnd / things / thermostat / properties / targetTemperature" temperature_state_topic: "home / Thermostat-P1 / stat / things / thermostat / properties" temperature_state_template: "{{value_json.targetTemperature}}" current_temperature_topic: "home / Thermostat-P1 / stat / things / thermostat / properties" current_temperature_template: "{{value_json.temperature}}" payload_on: "true" payload_off: "false" modes: ["heat", "auto", "off"] min_temp: 10 max_temp: 35 temp_step: 0.5

grbasta avatar Feb 10 '21 13:02 grbasta

It surely works, as I've based my own firmware on codes found in this repository, I can even send weather infos to it ;) WhatsApp Image 2021-01-13 at 10 37 11 AM

@nwaelti -- could you bring some light on how you did the trick to send weather info to it? Any pointers?

badger707 avatar Feb 12 '21 20:02 badger707

Hi @badger707 .

Here is some info on the weather:

  1. Enabling the function of obtaining weather data (optional)
  2. Sending weather data (optional)

I have sent bytes from the example to the thermostat and all the icons appeared.

Cheers, Mateusz

f3nix avatar Feb 13 '21 04:02 f3nix

It looks like this thermostat uses newer api for producut information.

It is version 0x03.

Querying product information

This (0x03) version returns in JSON format.

Cheers, Mateusz

f3nix avatar Feb 13 '21 04:02 f3nix

Sure, @badger707 , here's what I'm sending:

For UV/humidity/windlevel:

unsigned char wData[54] = {
  0x55, 0xAA, 0x00, 0x21, 0x00, 0x30, 0x01, 0x0A, 0x77, 0x2E, 0x68, 0x75,
  0x6D, 0x69, 0x64, 0x69, 0x74, 0x79, 0x00, 0x04, 0x00, 0x00, 0x00, humidity,
  0x05, 0x77, 0x2E, 0x75, 0x76, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, uv,
  0x0B, 0x77, 0x2E, 0x77, 0x69, 0x6E, 0x64, 0x4C, 0x65, 0x76, 0x65, 0x6C,
  0x00, 0x04, 0x00, 0x00, 0x00, windlevel
};

And the for the weather condition icon:

// 0=Sunny, 1=Rainy, ?=Cloudy
	if (condition == 0) {
 		unsigned char rawData[27] = {
			0x55, 0xAA, 0x00, 0x21, 0x00, 0x15, 0x01, 0x0B, 0x77, 0x2E, 0x63, 0x6F,
			0x6E, 0x64, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x01, 0x06, 0xE6, 0x99, 0xB4,
			0xE4, 0xBA, 0x91
		};
		commandCharsToSerial(27, rawData);
	} else if (condition == 1) {
		unsigned char rawData[27] = {
			0x55, 0xAA, 0x00, 0x21, 0x00, 0x15, 0x01, 0x0B, 0x77, 0x2E, 0x63, 0x6F,
			0x6E, 0x64, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x01, 0x06, 0xE4, 0xB8, 0xAD,
			0xE9, 0x9B, 0xA8
		};
		commandCharsToSerial(27, rawData);
	} else {
		unsigned char rawData[27] = {
			0x55, 0xAA, 0x00, 0x21, 0x00, 0x15, 0x01, 0x0B, 0x77, 0x2E, 0x63, 0x6F,
			0x6E, 0x64, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x01, 0x06, 0xE5, 0xA4, 0x9A,
			0xE4, 0xBA, 0x91
		};

nwaelti avatar Feb 13 '21 09:02 nwaelti

Hi @mwaelti, but how is it implemented? need to change the firmware? I don't have the right skills. A step by step guide? Thank you.

grbasta avatar Feb 13 '21 10:02 grbasta

@grbasta - I think these lines has to be baked into correct place within firmware, and then there must be some side process which is sending/pushing updated forecast information remotely to thermostat... Node Red maybe...?

@nwaelti and @f3nix -- big thanks for directions and code! I understand we'd need to send these commands to mcu, but question would be how you're sending all these commands while developing/exploring and before compiling? I have VScode with PlatformIO and I'm able to compile all this from source just fine. However I'm struggling to understand how you all folks sending these testing commands to mcu before compiling so you could capture mcu response and write needed code/functions and then compile.. That remains a mystery for me.... I'm not a dev or software engineer, just learning... Any guidance/advise on this?

badger707 avatar Feb 13 '21 14:02 badger707

@badger707 There are actually two ways of seeing things: The first one is to read and understand the Tuya protocol that @f3nix mentioned above, this link display how to send weather data to the MCU you can see in my first code part above that I'm sending 0x55 0xAA 0x00 0x21 < That one for instance is the command for weather data. In my firmware I created a MQTT function that allowed me to send raw Hex codes to the MCU, so I can directly try several hex codes and receive back what the MCU responded. The other way, which I did in the begining was to solder a FTDI TTL to the rx and tx pins of the TYWE3S module to listen to what was going on... But really the whole thing is written down in the Tuya Serial Prototol documentation :)

nwaelti avatar Feb 13 '21 15:02 nwaelti

On the other side, I've a NodeJS application that request OpenWeather weather through an API and sends a MQTT command to the thermostat which is then interpreted and converted to a hex command.

nwaelti avatar Feb 13 '21 15:02 nwaelti

@grbasta A step by step guide would be hard to write, You need to be at least able to build your own custom firmware using PlatformIo in order to start with... and as I stated in the begining, I'm not working with the firmware from fashberg at all, I've my own code, I just responded to this thread because it's the only one I found mentionning the BHT-8000.

nwaelti avatar Feb 13 '21 15:02 nwaelti

@grbasta -- one of ways to compile firmware would be to install Visual Studio Code, then go to Extensions and install PlatformIO IDE. This will install all additional things needed (like C++). Once PIO install finished go to PIO Home page > platforms > embedded > search for "espessif" ans install [Espressif 8266].

VSCode_platformio1 VScode_platformio2

Then you'd be following original instructions:

git clone https://github.com/fashberg/WThermostatBeca cd WThermostatBeca git submodule init git submodule update

Open this (WThermostatBeca) folder with VSCode and your ready to rock. You'd be editing WBecaDevice.h file file

build versioning is in platformio.ini, look at row 22

Then you'd be compiling with "build" build

Hope this helps.

badger707 avatar Feb 13 '21 17:02 badger707

@nwaelti -- thanks for notes. Agree, digesting all Tuya protocol would be preferred way to go, I've read through the sections mentioned by @f3nix (thanks!). Overall this makes sense (I think), but learning curve is steep and requires lots of time to understand all bells and whistles for bare minimum results. In my firmware I created a MQTT function that allowed me to send raw Hex codes to the MCU -- thats really handy! I appreciate your guidance & help, cheers!

Edit: removed unneeded part of comment

badger707 avatar Feb 13 '21 17:02 badger707