j0ta29 / esphome

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
https://esphome.io/
Other
7 stars 3 forks source link

3 Byte Data - feature request #14

Open 80morpheus opened 6 months ago

80morpheus commented 6 months ago

@j0ta29 @bertmelis

thanks for your great work. im already testing your library and its working perfect for me.

In some of the heatpumps there are 3 byte values. for example the outside temperature "AUSSEN" with address 0x01C1 shown in https://github.com/openv/openv/wiki/Adressen-W%C3%A4rmepumpen-Vitotronic-WO1C

for now im just using the vitoconnect library from dannerph https://github.com/dannerph/esphome_vitoconnect/tree/master i just added some code in the vitoconnect_sensor.cpp -> if (_length == 3){ int16_t tmp = 0; tmp = data[2] << 16 | data[1] << 8 | data[0]; float value = tmp / 1.0f; publish_state(value); }

it would awesome if you could add something similar to your librarys in the VitoWifi DPTypes.cpp adding some conv3_1_US in the esphome part there is i think something more to do.

j0ta29 commented 4 months ago

@80morpheus, please help me to understand your code snippet. If you bit shift data[2] 16 bits to the left then the value of this byte does not affect the value of tmp at all, imho. What about you just create a 2-byte-sensor with data[0] and data[1]? I never heard of 3-byte datapoints before. Unfortunately your first URL doesn't lead me to any Viessmann datapoint documentation.

80morpheus commented 4 months ago

@j0ta29 I have found a list with addresses in the openv page... https://github.com/openv/openv/wiki/Adressen-Wärmepumpen-Vitotronic-WO1C I have a Vitocal 200 A with the W01C type and they are all working fine.

Somewhere down there you can see the sensors "mitstatus" - "with state". For example starting at address 0x01C0. They have a additional byte for the state. Which I'm not using. That's why I'm just using the first two bytes. There are also some switches with state as you can see in the list. Starting with address 0x03C0.

I managed to find out how to do this already. Compiling with the latest EspHome 24.7.1 is working. https://github.com/80morpheus/esphome_viessmann_optolink/tree/main

j0ta29 commented 4 months ago

@80morpheus , as far as I can see, you just added a case-block in optolink_sensor_base.cpp for 3-byte-datapoints. This case-block is copy of the 2-byte-block. Wouldn't you get the same result, if you configure the datapoint as a 2-byte-datapoint?

80morpheus commented 4 months ago

@j0ta29 im so sorry. that was the wrong link. https://github.com/80morpheus/esphome_optolink/tree/optolink

you can't just ask the heat pump for two bytes at a three byte value. you would just get an error. you need to ask for 3 bytes and after you just throw away the third status byte. or else you could make another esphome binary from this.

datapoint_component - add case 3 DPTypes - add conv3_1_us conv3_10_F sensor/init.py - CONF_BYTES add 3