klausahrenberg / WThermostatBeca

Replaces original Tuya firmware on Beca thermostat with ESP8266 wifi module
395 stars 96 forks source link

Relay states #17

Closed uls169 closed 4 years ago

uls169 commented 5 years ago

Hi, do I understand well that I can't get status of relay with this firmware? I don't want to set it manually, but it is good to see when thermostat's relay is on or off back in home automation software (hass in my case). Thanks.

ghost commented 5 years ago

with automation rules you could check if actualTemperature < desiredTemperature -> relay is on.

How did you do the configuration in home assistant? Can you share your config for the themostat?

uls169 commented 5 years ago

Good idea with automation rule, but I think this way we could use as fault verification only. Of course it is only an opinion. I don't know if the thermostat MCU sends state of relay to ESP. If not, my idea is nonsense. I have not configured it in my production HASS server yet, I have this device installed for year with original FW, now I flashed klaus one and I only tried to check status and set it via mqtt (on my test HASS server). I asked for relay state in the moment when I thought about reasonable integration. Every relay device what I saw had state feedback (from sonoff to xiaomi or z-wave fibarro or heatit) if I remember well. How I said, it's just idea, I don't know if it can be implemented well.

cclein commented 5 years ago

I could see that being usefull. When the relay is on your home automation system triggers a ceiling fan, etc...

uls169 commented 5 years ago

Or simply for power consumption calculation.

bikemike commented 4 years ago

The MCU doesn't send the relay state. You would need to modify the board to hook the relay control pin on the MCU up to a gpio pin on the ESP. Then you'd need to modify the code as well.

I have done this and it works well but I'm using my own custom firmware.

Here is a pic of the board mod. I added a 10k/10k voltage divider to drop the MCU voltage from 5 to 2.5v.

MVIMG_20191108_231026

uls169 commented 4 years ago

@bikemike mike, thanks, simple idea, simple solution. Can you provide code diff so we can check your changes? Or firmware file as @pmaster555 mentioned in post above?

fabcia commented 4 years ago

@bikemike, I join the @pmaster555 and @uls169 requests for changes (diff in code) or firmware. I hope to have your news soon ....

bikemike commented 4 years ago

I have some code that does this in my C17GH3 thermostat repository here:

https://github.com/bikemike/C17GH3Thermostat/blob/master/src/main.cpp#L35

Search for PIN_RELAY_MONITOR and relayOn

I'm adding support for my BHT-002-GBLW to that codebase but I haven't quite finished it yet. I'll post again when I get it working reasonably well with Home Assistant and the MQTT HVAC component.

klausahrenberg commented 4 years ago

The device has no flag for relay working or not. I like the solution of bikemike. Maybe I will include the flag in my firmware also. At the tyua module are almost all IOs available, to use this for relay state is a good idea.

bikemike commented 4 years ago

I've added support for BHT-002-GBLW to my firmware now but be warned that it isn't very user friendly. It requires changing the timezone in code and compiling - both of which I haven't documented yet.

https://github.com/bikemike/MikesThermostat

coldfire84 commented 4 years ago

Is there something we can do here that's purely software? i.e. some logic in the formware that works out target temperature, set point, whether heating schedule is active or manual mode is enabled and returns what is, in effect, the state of the relay?

@bikemike, does your hardware modification allow for control of the relay, or is it simply state only?

bikemike commented 4 years ago

You could probably compute the state of the relay but I don't think the "deadzone temperature" setting is transmitted from the MCU so you would have to have an additional setting for that on the wifi module. For me it was just easier to solder a wire.

If you want to control the relay then you would have to make additional hardware changes. I did this for another thermostat I have (C17GH3) so I could control two relays (for baseboard electric and a gas fireplace). I disconnected the MCU from the relay and rewired so the wifi module reads the state from the MCU and controls both relays.

valepe commented 4 years ago

Does anyone can tell me where solder the voltage divider on the BHT-6000 thermostats? Link: BHT-6000 board

bikemike commented 4 years ago

@valepe You will need to check which pin on J1 connects to the relay control. If it is like my board(bac-002-wifi), the second from the bottom is GND, and 4th from the bottom is the relay pin.

klausahrenberg commented 4 years ago

Software solution for this hw modification is implemented now in 0.97

ahmaddxb commented 4 years ago

Software solution for this hw modification is implemented now in 0.97

Can you elaborate more on this? Do you still need to do the hardware mod or is this all done in software now.

klausahrenberg commented 4 years ago

Hi, ok to explain. This issue can not be solved by software only. The thermostat (MCU) definitily sends no state info of the heating relay. Please do the small modification that bikemike showed here: https://github.com/klausahrenberg/WThermostatBeca/issues/17#issuecomment-552078026 My firmware now asks for GPIO05 and sends the state. But it works only with this hardware modification.

ahmaddxb commented 4 years ago

@bikemike My board look like this. As you can see I have a J3Y on Q3 and Q4 as well as something on R9 and R10. How would I go about checking which connection point is needed to be made. Could i test is with a multimeter while turning on and off the relay by adjusting the temperature controls on the unit? Also what would I be looking for? Or could you tell me the correct way to approach this. Thanks

20190429_141805

realthk commented 4 years ago

It is a different setup indeed, though the board is the same, but your seems to have transistors where our version is left empty at Q3, Q4, only a 0 resistor on Q4: 20191211_121725 But as the panel is the same, the relay control line is most likely still on R10 and the affected leg of Q4 is also GND, so it should not be any different to get the signal. BTW, which model is that? Mine is this.

klausahrenberg commented 4 years ago

My board look like this. As you can see I have a J3Y on Q3 and Q4 as well as something on R9 and R10.

@ahmaddxb Could you let me know your exactly model? Does your model supports more function, like cooling/ventilation? And also, if the hw modification is also working at your model - I would wonder, if this would not work because layout is the same.

ahmaddxb commented 4 years ago

Yes mine has heating cooling and ventilation modes, model is BAC-002ALW used for 2 Pipe 3 Speed Central Air conditioner. I only use it for cooling side and wanted to monitor the state of the repay to know when the valve is opened on my AC.

https://www.aliexpress.com/item/32913037607.html?spm=a2g0s.9042311.0.0.27424c4dqwOdze

I haven't tried the hw mod yet i wanted to know a way to test if putting the wire in the same location as @bikemike if it could work on my model. Is there some test i could do with a multimeter while triggering the relay on and off with the unit by adjusting the temperature to above and below the desired temp.

bikemike commented 4 years ago

@ahmaddxb, yours probably has multiple relays so you will have to figure out which one is used for cooling and trace that back from the relay to the board. You'll have to disconnect the thermostat and use a multimeter to check continuity with the relay signal pin and the ribbon cable pins.

shin-01 commented 4 years ago

For some reasons, I think in BHT-6000 heating and off state are swapped...

OFF state: {"idx":"thermostatbeca_11482470","ip":"192.168.1.105","firmware":"1.00","temperature":20.50,"targetTemperature":20.00,"deviceOn":true,"schedulesMode":"off","state":"heating"}

On State: {"idx":"thermostatbeca_11482470","ip":"192.168.1.105","firmware":"1.00","temperature":20.50,"targetTemperature":22.50,"deviceOn":true,"schedulesMode":"off","state":"off"}

funtik039 commented 4 years ago

Hi all. I have BAC-2000WIfi. Its the same as BAC-002GALW. 6TXLQ8GLw38

But it have another board. Some one can help whis it? How to upgrade this termostat? IfB0O6tJ3As

In my logic it must be like this: mod

jodelflyer commented 4 years ago

I have been using your firmware for about 6months and it is working well. However, I want to cjhange the IP address it connects to. I have tried accessing it via the http:///config (using my IP) but it does not open. The state from the thermostat says "webServerRunning":false. I assume tis is the problem. How do I make it true

klausahrenberg commented 4 years ago

Ok, it seems you use a really old version, if the webserver is not running all the time. It changed from v1.00 on. If you want to update, keep in mind that mqtt topics also changed - take a look to the readme in this case. To activate the web Server. Switch thermostat off and press the 'down'-Button until the display blinks. Then the thermostat is in config mode and should start the webserver. Maybe it opens an own Wifi-Acces-Point, but normally it just starts the webserver and is available under http:// at this old version. Please check. Alternativally send a mqtt message /webServer and payload 'true' - this should start the config page too.

jodelflyer commented 4 years ago

Perfect. Thanks for the very quick response.

Tony

jodelflyer commented 4 years ago

Following on from the above, I had to reset my node red control of my thermostat after upgrading the firmware (even though you warned me about topic changes I did not see the full changes). Generally everything is working fine. However, I do not have any inputs to change the scheduleMode but find that the thermostat keeps changing to auto mode. All of my thermostat controls are in one flow. I have disabled it but the thermostat is still switching to auto. Is there an issue.

fyodorov-alexey commented 4 years ago

Hello everybody! If I understood right, this thermostat sets relay to start floor heating when air temperature on its body sensor is lower, than set as desired. Is there a possibility to bind the floor heating to the floor sensor temperature? That is very important for me in my use case. Alexey

ReachyBayern commented 4 years ago

Hardware change to get "heating" state for Beca Wifi thermostat (Kkmoon E8489W-2) Beca-Floor-Kkmoon-E8489W-2

R13 - R10K - GPIO5 - R10K - GND

GND is also there where the black mark is. But the chassis allows there less space.

Kind Regards

Roland

ReachyBayern commented 4 years ago

Hello everybody! If I understood right, this thermostat sets relay to start floor heating when air temperature on its body sensor is lower, than set as desired. Is there a possibility to bind the floor heating to the floor sensor temperature? That is very important for me in my use case. Alexey

yes, you can use the external sensor. see manual

[https://irshop.eu/eng/files/2017/11/BHT1000-WiFi-Eng-irshop.eu_.pdf]

grafik

fyodorov-alexey commented 4 years ago

yes, you can use the external sensor. see manual

[https://irshop.eu/eng/files/2017/11/BHT1000-WiFi-Eng-irshop.eu_.pdf]

Thank you very much for manual link! My thermostat slightly differs, and service menu differs too. The external NTC sensor selection is "OU". thermostat BTW, when NTC is chosen as a target sensor, MQTT temperature, posted by thermostat equals to floorTemperature. it’s bit a pity that can’t use the thermostat as an additional air temperature sensor.

GGW42 commented 4 years ago

Hi, I have just flashed my "BHT-002" "GCLW" with V1.11. Is the web interface really a text page? See attached image. image There doesn't seem to be a way to change any settings from this page, is this correct or have I made a mistake somewhere? I saw the graphic web interface just after flashing when it was an access point but have not been able to find it again. I want to add this mod to monitor the relay but am not sure how I can turn it on since there are no controls on my web interface? Any clues, i am really new to this so i probably missed something somewhere?

fashberg commented 4 years ago

@GGW42 Try: http://192.168.0.203/config

https://github.com/klausahrenberg/WThermostatBeca#initial-configuration

Initial configuration To setup the device model, network options and other parameters, follow instrcution here: https://github.com/klausahrenberg/WThermostatBeca/blob/master/Configuration.md After initial setup, the device configuration is still available via http:///config

GGW42 commented 4 years ago

Thanks @fashberg not sure how i missed that, it works well. I have now moded my unit so the "state" function now works. My unit has a PCB marked "bac-002-wifi-20190409" but looks the same as the "bac-002-wifi" unit above so I followed that mod. I have now installed unit on the wall and it continues to work well. Now I just have to work out how to get "Home Assistant" to see the MQTT messages that I can see being transmitted.

fashberg commented 4 years ago

Hey @GGW42 For homeassistant i suggest my fork and then just use autodiscovery. Use latest https://github.com/fashberg/WThermostatBeca/releases/tag/v1.16.beta3-fas which has also autodiscovery for BAC-002 climate control.

You can see also HASS manual config at my project startpage.

I currently have 2 problems with BAC-002 HASS supports only these modes: [“auto”, “off”, “cool”, “heat”, “dry”, “fan_only”] But BAC-002 has no full-auto-mode, you can switch between auto (scheduler) and manual and the mode can be switched between cool/heat/fan_only. How to map this to HASS. Any suggestions? Bug2: when changing fan-speed mode switches to fan_only

Please reply to https://github.com/fashberg/WThermostatBeca/issues/38 for fork-specific

Kind Regards Folke

GoNzCiD commented 4 years ago

You could probably compute the state of the relay but I don't think the "deadzone temperature" setting is transmitted from the MCU so you would have to have an additional setting for that on the wifi module. For me it was just easier to solder a wire.

If you want to control the relay then you would have to make additional hardware changes. I did this for another thermostat I have (C17GH3) so I could control two relays (for baseboard electric and a gas fireplace). I disconnected the MCU from the relay and rewired so the wifi module reads the state from the MCU and controls both relays.

Hi @bikemike, can you share what hardware mod is needed to control the relay with mqtt? Thanks

rumoldus commented 4 years ago

The MCU doesn't send the relay state. You would need to modify the board to hook the relay control pin on the MCU up to a gpio pin on the ESP. Then you'd need to modify the code as well.

I have done this and it works well but I'm using my own custom firmware.

Here is a pic of the board mod. I added a 10k/10k voltage divider to drop the MCU voltage from 5 to 2.5v.

MVIMG_20191108_231026

Hi @bikemike, could you describe in slightly more detail where you connect your resistors ? I think I see the open pad of Q4 and the nearby end of R10, but it is not entirely clear to me. Many thanks. Marcel

fashberg commented 4 years ago

@GoNzCiD

I have implemented RelayStateCalculation. The DeadZone configured in the Thermostate-setup (MCU) must be configured in WThermostat then you get the state

https://github.com/fashberg/WThermostatBeca

bikemike commented 4 years ago

Hi @bikemike, could you describe in slightly more detail where you connect your resistors ? I think I see the open pad of Q4 and the nearby end of R10, but it is not entirely clear to me. Many thanks. Marcel

Yes, one resistor connects to the open pad and the other resistor connects to the end of the 0 ohm resistor on what in guess could be R10(I dont see a label for it though).

The other ends of the two 10k resistors are soldered together and that is where you solder the wire to as well.

GoNzCiD commented 4 years ago

@fashberg, thanks. I was trying to control the relay, not only check the real state. Do you know if it's possible and the needed hardware mod?

Thanks

bttfw commented 4 years ago

Hi all. I have BAC-2000WIfi. Its the same as BAC-002GALW. 6TXLQ8GLw38

But it have another board. Some one can help whis it? How to upgrade this termostat? IfB0O6tJ3As

In my logic it must be like this: mod

Did you ever figure it out ??

gavlexx commented 3 years ago

Mine BHT002-GBLW board is like this. Found that when relay is on - there is 5V between 1 and 2 (from top) pins of J2. Otherwise 0V. Getting 5V through divider to GPIO pin and have profit! :) photo_2020-11-28_16-51-13

frtz13 commented 3 years ago

Mine BHT002-GBLW board is like this. Found that when relay is on - there is 5V between 1 and 2 (from top) pins of J2. Otherwise 0V. Getting 5V through divider to GPIO pin and have profit! :)

I got the same board (model : BHT-002-GCLW), and had a closer look at J2. pin 3 is GND. Pin 2 is 0V when heating, 5V when heating is off. I put a voltage divider (2 x 15kOhm) between pin 2 and 3 and connected the middle point to GPIO5. NB: you will have to make some room for the resistors in the plastic rear enclosure. BHT-002-relayhack

However, in Wthermostat 1.19beta1-fas with configured heating relay connection at GPIO 5, I get the inverted heating state on the Info page, and through MQTT. The inverted state through MQTT is not a big problem if you use it in Home Assistant. The state can be inverted again in the climate configuration section:

climate:
  - platform: mqtt
(…)
    action_template:  >
      {% if value_json.action == "heating" %}
        idle
      {% elif value_json.action == "idle" %}
        heating
      {% endif %}
(…)

@fashberg Maybe in a future release we can get one more configuration option in the drop-down list: heating relay connection at GPIO 5 (low=active)…

gavlexx commented 3 years ago
I got the same board (model : BHT-002-GCLW), and had a closer look at J2. pin 3 is GND. Pin 2 is 0V when heating, 5V when heating is off.
I put a voltage divider (2 x 15kOhm) between pin 2 and 3 and connected the middle point to GPIO5.

If you put voltage divider between pin 1 and 3 of J2 - you receive non-inverted heating state without need in MQTT adjusting :)

frtz13 commented 3 years ago

voltage divider between pin 1 and 3 of J2

pin 3 is GND, at same potential as the ESP8266 GND pin. according to my measure, pin 1 is 5V, regardless of relay state (can't do it again, thermostat is now taking care of the heater...). voltage divider between pins 1 and 3 does not make sense to me, at least not with the signals on my board. btw, thermostat is working fine and the (inverted) relay state signal looks good with my pin 2/3 divider.

gabor60i commented 3 years ago

Mine BHT002-GBLW board is like this.

@frtz13: My board exactly the same. Sadly I have no experience in soldering so originally I planned to use tuya convert. As turned out it is not possible with this new tuya fw. So I would like to give it a try with soldering, but not find any reference picture of how to do it. I would appreciate if You share with me a picture of how to connect the pins. Thanks!

frtz13 commented 3 years ago

wiring info is here: https://github.com/klausahrenberg/WThermostatBeca/blob/master/Flashing.md good luck.

gabor60i commented 3 years ago

Do You mean, that regardless of the differences in the board, and the name of the components, the wiring is the same? I found this guide myself, but I was disappointed because the differences was too obvious.

frtz13 commented 3 years ago

yes, wiring is the same. it's the same ESP chip. I used this guide and everything worked as expected.