Configured my ESPHome with MCP2515 CAN-Bus for Stiebel Eltron heating pump

Thanks for these hints. I will give it a try when I am back from business travel.

I see two separate scenarios for the two approaches.

  1. storing PV electricity. Your solution to force the hot water production definitely makes sense.

  2. do not run the heating at night, if the following day is expected to be very sunny or surprisingly high temperature.

For the latter I see a big savings potential for us, so I would be very interested to automate this, or at least have it manually controllable via Home Assistant.

Do you still have the program code to switch between Eco and Comfort or could you give me a tip on how to do that?
Thanks in advance

Hey all,

Thank you all for sharing your achievements!

I’ve successfully connected esp32 with mcp2515 to my WPM4 module and getting some data.
None of the hex data received match on frame if statements

08:40:14][D][canbus:070]: received can message (#1) std can_id=0x480 size=7
[08:40:14][I][main:1491]: Antwort von 480 Hex: a1 0 fa 1 d6 0 0
[08:40:14][I][main:1492]: Antwort von 480 Float: 0.000000
[08:40:14][I][main:1493]: Antwort von 480 Dez.: 0 0
[08:40:14][I][main:1494]: Antwort klein von 480 Float: 470.000000
[08:40:14][I][main:1495]: Antwort klein von 480 Dez.: 1 214
[08:40:14][D][canbus:070]: received can message (#2) std can_id=0x480 size=7
[08:40:14][I][main:1491]: Antwort von 480 Hex: a1 0 fa 7 a8 0 0
[08:40:14][I][main:1492]: Antwort von 480 Float: 0.000000
[08:40:14][I][main:1493]: Antwort von 480 Dez.: 0 0
[08:40:14][I][main:1494]: Antwort klein von 480 Float: 1960.000000
[08:40:14][I][main:1495]: Antwort klein von 480 Dez.: 7 168
[08:24:33][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[08:24:33][I][main:1435]: Antwort von 180 Hex: a0 79 c 0 60 0 0
[08:24:33][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:33][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:33][I][main:1438]: Antwort klein von 180 Float: 96.000000
[08:24:33][I][main:1439]: Antwort klein von 180 Dez.: 0 96
[08:24:37][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[08:24:37][I][main:1435]: Antwort von 180 Hex: 60 79 16 80 0 0 0
[08:24:37][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:37][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:37][I][main:1438]: Antwort klein von 180 Float: 32768.000000
[08:24:37][I][main:1439]: Antwort klein von 180 Dez.: 128 0
[08:24:42][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[08:24:42][I][main:1435]: Antwort von 180 Hex: 60 79 16 80 0 0 0
[08:24:42][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:42][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:42][I][main:1438]: Antwort klein von 180 Float: 32768.000000
[08:24:42][I][main:1439]: Antwort klein von 180 Dez.: 128 0
[08:24:44][D][canbus:070]: received can message (#7) std can_id=0x180 size=7
[08:24:44][I][main:1435]: Antwort von 180 Hex: 60 79 16 80 0 0 0
[08:24:44][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:44][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:44][I][main:1438]: Antwort klein von 180 Float: 32768.000000
[08:24:44][I][main:1439]: Antwort klein von 180 Dez.: 128 0
[08:24:45][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[08:24:45][I][main:1435]: Antwort von 180 Hex: 60 79 16 80 0 0 0
[08:24:45][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:45][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:45][I][main:1438]: Antwort klein von 180 Float: 32768.000000
[08:24:45][I][main:1439]: Antwort klein von 180 Dez.: 128 0
[08:24:48][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[08:24:48][I][main:1435]: Antwort von 180 Hex: a0 79 c 0 5f 0 0
[08:24:48][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:48][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:48][I][main:1438]: Antwort klein von 180 Float: 95.000000
[08:24:48][I][main:1439]: Antwort klein von 180 Dez.: 0 95
[08:24:48][D][canbus:070]: received can message (#4) std can_id=0x180 size=7
[08:24:48][I][main:1435]: Antwort von 180 Hex: 60 79 16 80 0 0 0
[08:24:48][I][main:1436]: Antwort von 180 Float: 0.000000
[08:24:48][I][main:1437]: Antwort von 180 Dez.: 0 0
[08:24:48][I][main:1438]: Antwort klein von 180 Float: 32768.000000
[08:24:48][I][main:1439]: Antwort klein von 180 Dez.: 128 0
[08:40:14][D][canbus:070]: received can message (#3) std can_id=0x480 size=7
[08:40:14][I][main:1491]: Antwort von 480 Hex: a0 0 fa 9 17 fd 66
[08:40:14][I][main:1492]: Antwort von 480 Float: 64870.000000
[08:40:14][I][main:1493]: Antwort von 480 Dez.: 253 102
[08:40:14][I][main:1494]: Antwort klein von 480 Float: 2327.000000
[08:40:14][I][main:1495]: Antwort klein von 480 Dez.: 9 23
[08:40:14][D][canbus:070]: received can message (#4) std can_id=0x500 size=7
[08:40:14][I][main:1454]: Antwort von 180 Hex: 92 0 fa 1 d6 0 f1
[08:40:14][I][main:1455]: Antwort von 180 Float: 241.000000
[08:40:14][I][main:1456]: Antwort von 180 Dez.: 0 241
[08:40:14][I][main:1457]: Antwort klein von 180 Float: 470.000000
[08:40:14][I][main:1458]: Antwort klein von 180 Dez.: 1 214
[08:40:14][D][canbus:070]: received can message (#5) std can_id=0x500 size=7
[08:40:14][I][main:1454]: Antwort von 180 Hex: 92 0 16 0 b1 0 0
[08:40:14][I][main:1455]: Antwort von 180 Float: 0.000000
[08:40:14][I][main:1456]: Antwort von 180 Dez.: 0 0
[08:40:14][I][main:1457]: Antwort klein von 180 Float: 177.000000
[08:40:14][I][main:1458]: Antwort klein von 180 Dez.: 0 177
[08:40:14][D][canbus:070]: received can message (#6) std can_id=0x500 size=7
[08:40:14][I][main:1454]: Antwort von 180 Hex: 92 0 fa 7 a8 0 8
[08:40:14][I][main:1455]: Antwort von 180 Float: 8.000000
[08:40:14][I][main:1456]: Antwort von 180 Dez.: 0 8
[08:40:14][I][main:1457]: Antwort klein von 180 Float: 1960.000000
[08:40:14][I][main:1458]: Antwort klein von 180 Dez.: 7 168
[08:40:14][D][canbus:070]: received can message (#7) std can_id=0x480 size=7
[08:40:14][I][main:1491]: Antwort von 480 Hex: a1 0 fa a 36 0 0
[08:40:14][I][main:1492]: Antwort von 480 Float: 0.000000
[08:40:14][I][main:1493]: Antwort von 480 Dez.: 0 0
[08:40:14][I][main:1494]: Antwort klein von 480 Float: 2614.000000
[08:40:14][I][main:1495]: Antwort klein von 480 Dez.: 10 54
[08:40:14][D][canbus:070]: received can message (#8) std can_id=0x180 size=7
[08:40:14][I][main:1436]: Antwort von 180 Hex: a0 0 fa 1 d7 1 17
[08:40:14][I][main:1437]: Antwort von 180 Float: 279.000000
[08:40:14][I][main:1438]: Antwort von 180 Dez.: 1 23
[08:40:14][I][main:1439]: Antwort klein von 180 Float: 471.000000
[08:40:14][I][main:1440]: Antwort klein von 180 Dez.: 1 215
[08:40:14][D][canbus:070]: received can message (#9) std can_id=0x480 size=7
[08:40:14][I][main:1491]: Antwort von 480 Hex: a0 0 fa 4e 30 0 0
[08:40:14][I][main:1492]: Antwort von 480 Float: 0.000000
[08:40:14][I][main:1493]: Antwort von 480 Dez.: 0 0
[08:40:14][I][main:1494]: Antwort klein von 480 Float: 20016.000000
[08:40:14][I][main:1495]: Antwort klein von 480 Dez.: 78 48

config



#WW_Programm

          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x17,0xa0,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM NE WW Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x24,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM NE WW Summe mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x25,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#WM NE Heizen Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x28,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM NE Heizen Summe mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x29,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#WM WW Tag wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2a,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM WW Tag kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2b,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM WW Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2c,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM WW Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2d,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM Heizen Tag wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2e,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM Heizen Tag kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2f,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM Heizen Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x30,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM Heizen Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x31,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms






#el. Leistungsaufnahme WW Tag Wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1a,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme WW Tag kWh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1b,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#el. Leistungsaufnahme WW Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1c,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme WW Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1d,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#el. Leistungsaufnahme Heizen Tag Wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1e,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme Heizen Tag Wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1f,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#el. Leistungsaufnahme Heizen Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x20,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme Heizen Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x21,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


          - lambda: |-
              if (id(waermemertrag_electr_ww_total_mWh_flag) and id(waermemertrag_electr_ww_total_kWh_flag)){
              id(waermemertrag_electr_ww_total_mWh) += id(waermemertrag_electr_ww_total_kWh_float);
              id(total_electric_heating_energy_water).publish_state(id(waermemertrag_electr_ww_total_mWh));
              id(ww_cop_ertrag_electr_flag)=true;
              };
              id(waermemertrag_electr_ww_total_mWh_flag)=false;
              id(waermemertrag_electr_ww_total_kWh_flag)=false;


          - lambda: |-
              if (id(waermemertrag_electr_heiz_total_kWh_flag) and id(waermemertrag_electr_heiz_total_mWh_flag)){
              id(waermemertrag_electr_heiz_total_mWh) += id(waermemertrag_electr_heiz_total_kWh_float);
              id(total_electric_heating_energy).publish_state(id(waermemertrag_electr_heiz_total_mWh));
              id(heat_cop_ertrag_electr_flag)=true;
              };
              id(waermemertrag_electr_heiz_total_kWh_flag)=false;
              id(waermemertrag_electr_heiz_total_mWh_flag)=false;
       

          - lambda: |-
              if (id(waermemertrag_ww_total_mWh_flag) and id(waermemertrag_ww_total_kWh_flag)){
              id(waermemertrag_ww_total_mWh) += id(waermemertrag_ww_total_kWh_float);
              id(total_heating_energy_water).publish_state(id(waermemertrag_ww_total_mWh));
              id(ww_cop_ertrag_flag)=true;
              };
              id(waermemertrag_ww_total_mWh_flag)=false;
              id(waermemertrag_ww_total_kWh_flag)=false;

          - lambda: |-
              if (id(waermemertrag_heiz_total_kWh_flag) and id(waermemertrag_heiz_total_mWh_flag)){
              id(waermemertrag_heiz_total_mWh) += id(waermemertrag_heiz_total_kWh_float);
              id(total_heating_energy).publish_state(id(waermemertrag_heiz_total_mWh));
              id(heat_cop_ertrag_flag)=true;
              };
              id(waermemertrag_heiz_total_kWh_flag)=false;
              id(waermemertrag_heiz_total_mWh_flag)=false;
       
          - lambda: |-
              if (id(waermemertrag_heiz_tag_kwh_flag) and id(waermemertrag_heiz_tag_wh_flag)){
              id(waermemertrag_heiz_tag_kwh) += id(waermemertrag_heiz_tag_wh_float);
              id(daily_heating_energy).publish_state(id(waermemertrag_heiz_tag_kwh));
              };
              id(waermemertrag_heiz_tag_kwh_flag)=false;
              id(waermemertrag_heiz_tag_wh_flag)=false;

          - lambda: |-
              if (id(waermemertrag_ww_tag_kwh_flag) and id(waermemertrag_ww_tag_wh_flag)){
              id(waermemertrag_ww_tag_kwh) += id(waermemertrag_ww_tag_wh_float);
              id(daily_heating_energy_water).publish_state(id(waermemertrag_ww_tag_kwh));
              };
              id(waermemertrag_ww_tag_kwh_flag)=false;
              id(waermemertrag_ww_tag_wh_flag)=false;



          - lambda: |-
              if (id(el_aufnahmeleistung_ww_total_mWh_flag) and id(el_aufnahmeleistung_ww_total_kWh_flag)){
              id(el_aufnahmeleistung_ww_total_mWh) += id(el_aufnahmeleistung_ww_total_kWh_float);
              id(total_electric_energy_water).publish_state(id(el_aufnahmeleistung_ww_total_mWh));
              id(ww_cop_electr_leistung_flag)=true;
              };
              id(el_aufnahmeleistung_ww_total_mWh_flag)=false;
              id(el_aufnahmeleistung_ww_total_kWh_flag)=false;

          - lambda: |-
              if (id(el_aufnahmeleistung_heiz_total_mWh_flag) and id(el_aufnahmeleistung_heiz_total_kWh_flag)){
              id(el_aufnahmeleistung_heiz_total_mWh) += id(el_aufnahmeleistung_heiz_total_kWh_float);
              id(total_electric_energy_heating).publish_state(id(el_aufnahmeleistung_heiz_total_mWh));
              id(heat_cop_electr_leistung_flag)=true;
              };
              id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;
              id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;       

          - lambda: |-
              if (id(el_aufnahmeleistung_ww_tag_kwh_flag) and id(el_aufnahmeleistung_ww_tag_wh_flag)){
              id(el_aufnahmeleistung_ww_tag_kwh) += id(el_aufnahmeleistung_ww_tag_wh_float);
              id(daily_electric_energy_water).publish_state(id(el_aufnahmeleistung_ww_tag_kwh));
              };
              id(el_aufnahmeleistung_ww_tag_kwh_flag)=false;
              id(el_aufnahmeleistung_ww_tag_wh_flag)=false;

          - lambda: |-
              if (id(el_aufnahmeleistung_heiz_tag_kwh_flag) and id(el_aufnahmeleistung_heiz_tag_wh_flag)){
              id(el_aufnahmeleistung_heiz_tag_kwh) += id(el_aufnahmeleistung_heiz_tag_wh_float);
              id(daily_electric_energy_heating).publish_state(id(el_aufnahmeleistung_heiz_tag_kwh));
              };
              id(el_aufnahmeleistung_heiz_tag_kwh_flag)=false;
              id(el_aufnahmeleistung_heiz_tag_wh_flag)=false;

#Berechnung Coefficient of Performance (COP)
          - lambda: |-
              if (id(ww_cop_ertrag_electr_flag) and id(ww_cop_ertrag_flag) and id(ww_cop_electr_leistung_flag)){
              id(ww_cop_float) = (id(waermemertrag_ww_total_mWh)+id(waermemertrag_electr_ww_total_mWh))/id(el_aufnahmeleistung_ww_total_mWh);
              id(cop_water).publish_state(id(ww_cop_float));
              id(ww_cop_flag)=true;
              };
              id(ww_cop_ertrag_electr_flag)=false;
              id(ww_cop_ertrag_flag)=false;
              id(ww_cop_electr_leistung_flag)=false;

          - lambda: |-
              if (id(heat_cop_ertrag_electr_flag) and id(heat_cop_ertrag_flag) and id(heat_cop_electr_leistung_flag)){
              id(heat_cop_float) = (id(waermemertrag_heiz_total_mWh)+id(waermemertrag_electr_heiz_total_mWh))/id(el_aufnahmeleistung_heiz_total_mWh);
              id(cop_heater).publish_state(id(heat_cop_float));
              id(heat_cop_flag)=true;
              };
              id(heat_cop_ertrag_electr_flag)=false;
              id(heat_cop_ertrag_flag)=false;
              id(heat_cop_electr_leistung_flag)=false;

          - lambda: |-
              if (id(heat_cop_flag) and id(ww_cop_flag)){
              id(total_cop_float) = ((id(waermemertrag_heiz_total_mWh)+id(waermemertrag_electr_heiz_total_mWh))+(id(waermemertrag_ww_total_mWh)+id(waermemertrag_electr_ww_total_mWh)))/(id(el_aufnahmeleistung_heiz_total_mWh)+id(el_aufnahmeleistung_ww_total_mWh));
              id(cop_total).publish_state(id(total_cop_float));
              };
              id(heat_cop_flag)=false;
              id(ww_cop_flag)=false;






#Außentemperatur 1/10 °C et dec value
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x00,0x0c,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WW Speicher IST
          - canbus.send:
              data: [ 0x31, 0x00, 0x0e,0x00,0x00,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 


#RĂŒcklauftemperatur Hzg - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x00,0x16,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 


#WW Soll-Temperatur
          - canbus.send:
              data: [ 0x31, 0x00, 0x03,0x00,0x00,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 

#Quelle IST: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x01,0xd4,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 



#  { "HEISSGAS_TEMP"                                    , 0x0265, et_dec_val}
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x02,0x65,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#T_Heizkreis_IST Abfrage: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x02,0xca,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 
#T_Heizkreis_Soll Abfrage: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x01,0xd7,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 

#Warmwasser Betriebsmodus Abfrage: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x01,0x12,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WW Eco Soll Abfrage
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x0a,0x06,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WW Komfort Soll Abfrage
          - canbus.send:
              data: [ 0x31, 0x00, 0x13,0x00,0x00,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms




spi:
  id: McpSpi
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19




canbus:
  - platform: mcp2515
    id: my_mcp2515
    spi_id: McpSpi
    cs_pin: GPIO17
    can_id: 680
    use_extended_id: false
    bit_rate: 20kbps
    on_frame:



#T Heizkreis WW Komfort Soll Abfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0x13) {
              float temperature =(float((int16_t((x[4])+( (x[3])<<8))))/10);
              id(ww_temp_komfort_log).publish_state(temperature);
              ESP_LOGD("main", "T Komfort Soll empfangen over can is %f", temperature);
            }
#T Heizkreis WW Eco Soll Abfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x0a and x[4]==0x06) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10);
              id(ww_temp_eco_log).publish_state(temperature);
              ESP_LOGD("main", "T Eco Soll empfangen over can is %f", temperature);
            }


#T Heizkreis IST Abfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x02 and x[4] == 0xca) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10);
              id(t_heizkreis_ist).publish_state(temperature);
              ESP_LOGD("main", "T Heizkreis IST empfangen over can is %f", temperature);
            }
#T Heizkreis Soll Abfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x01 and x[4] == 0xd7) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10);
              id(t_heizkreis_soll).publish_state(temperature);
              ESP_LOGD("main", "T Heizkreis Soll empfangen over can is %f", temperature);
            }
#T WW Soll Abfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0x03) {
              float temperature =(float((int16_t((x[4])+( (x[3])<<8))))/10);
              id(t_ww_soll).publish_state(temperature);
              ESP_LOGD("main", "T Warmwasser Soll empfangen over can is %f", temperature);
            }


#WW Programm Start- und Ende-Zeit
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x17 and x[4]==0xa0 ) {
              int start = int(x[5]);
              int ende = int(x[6]);
              id(ww_start).publish_state(start);
              id(ww_ende).publish_state(ende);
              ESP_LOGD("main", "Warmwasser Programmzeit Start und Ende empfangen over can is %i %i", start, ende);
            }



#Warmwasser Betriebsmodus
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x01 and x[4]==0x12) {
              if (x[5]==0x00){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Notbetrieb");
                call.perform();}
              else if (x[5]==0x01){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Bereitschaft");
                call.perform();}
              else if (x[5]==0x02){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Automatik");
                call.perform();}
              else if (x[5]==0x03){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Komfort");
                call.perform();}
              else if (x[5]==0x04){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Eco");
                call.perform();}
              else if (x[5]==0x05){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Warmwasserbetrieb");
                call.perform();}
              }



#Warmwasser-Temperaturabfrage + individueller Offset (3.9 °C)
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0e) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10)+3.9;
              id(temperature_water).publish_state(temperature);
              ESP_LOGD("main", "Warmwasser-Temperature empfangen over can is %f", temperature);
            }
#Quellen-Temperaturabfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x01 and x[4] == 0xd4) {
              float temperature =float((int16_t((x[6])+( (x[5])<<8))))/10;
              id(temperature_source).publish_state(temperature);
              ESP_LOGD("main", "Quellen-Temperature received over can is %f", temperature);
            }

#Speicher IST-temperaturabfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0x0e) {
              float temperature =float((int16_t((x[4])+( (x[3])<<8))))/10;
              id(t_ww_ist).publish_state(temperature);
              ESP_LOGD("main", "Speicher-Temperature received over can is %f", temperature);
            }

#RĂŒcklauftemperaturabfrage
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x16) {
              float temperature =float((int16_t((x[6])+( (x[5])<<8))))/10;
              id(temperature_return).publish_state(temperature);
              ESP_LOGD("main", "RĂŒcklauf-Temperature received over can is %f", temperature);
            }


#Außentemperaturabfrage
#float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0c) {
              float temperature =float((int16_t((x[6])+( (x[5])<<8))))/10;
              id(temperature_outside).publish_state(temperature);
              ESP_LOGD("main", "Aussen-Temperature received over can is %f", temperature);
            }

#Luftfeuchtigkeit FEK mitlesen
    - can_id: 0x301
      then:
        - lambda: |-
            if(x[0]==0xc0 and x[1]==0x01 and x[2]==0x75) {
              float humidity =float(float((int16_t((x[4])+( (x[3])<<8))))/10);
              id(humidity_inside).publish_state(humidity);
              ESP_LOGD("main", "Humidity received over can is %f", humidity);
            }

#Raumtemperatur FEK mitlesen
    - can_id: 0x301
      then:
        - lambda: |-
            if(x[0]==0xc0 and x[1]==0x01 and x[2]==0x11) {
              float temperature =float((int16_t((x[4])+( (x[3])<<8))))/10;
              id(temperature_inside).publish_state(temperature);
              ESP_LOGD("main", "Raum-Temperature received over can is %f", temperature);
            }

#Elektrische Leistungsaufnahme Wh /kWh
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if (x[4]==0x1a){
                id(el_aufnahmeleistung_ww_tag_wh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_ww_tag_wh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_ww_tag_kwh received over can is %f", id(el_aufnahmeleistung_ww_tag_wh_float));}
              else if (x[4]==0x1e){
                id(el_aufnahmeleistung_heiz_tag_wh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_heiz_tag_wh_flag) = true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_tag_wh received over can is %f", id(el_aufnahmeleistung_heiz_tag_wh_float));}
              else if (x[4]==0x1c){
                id(el_aufnahmeleistung_ww_total_kWh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_ww_total_kWh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_ww_total_kWh received over can is %f", id(el_aufnahmeleistung_ww_total_kWh_float));}
              else if (x[4]==0x20){
                id(el_aufnahmeleistung_heiz_total_kWh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_heiz_total_kWh_flag) = true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_total_kWh received over can is %f", id(el_aufnahmeleistung_heiz_total_kWh_float));}
              }

#Elektrische Leistungsaufnahme kWh / MWH
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if(x[4]==0x1b){
              id(el_aufnahmeleistung_ww_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
              id(el_aufnahmeleistung_ww_tag_kwh_flag)=true;
              ESP_LOGD("main", "el_aufnahmeleistung_ww_tag_kwh received over can is %f", id(el_aufnahmeleistung_ww_tag_kwh));}
              else if(x[4]==0x1f){
                id(el_aufnahmeleistung_heiz_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
                id(el_aufnahmeleistung_heiz_tag_kwh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_tag_kwh received over can is %f", id(el_aufnahmeleistung_heiz_tag_kwh));}
              else if(x[4]==0x1d){
              id(el_aufnahmeleistung_ww_total_mWh) =float(int((x[6])+( (x[5])<<8)));
              id(el_aufnahmeleistung_ww_total_mWh_flag)=true;
              ESP_LOGD("main", "el_aufnahmeleistung_ww_total_mWh received over can is %f", id(el_aufnahmeleistung_ww_total_mWh));}
              else if(x[4]==0x21){
                id(el_aufnahmeleistung_heiz_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(el_aufnahmeleistung_heiz_total_mWh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_total_mWh received over can is %f", id(el_aufnahmeleistung_heiz_total_mWh));}
            }


#WĂ€rmeertrag WW/Heizung MWh / kWH
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if(x[4]==0x25){
                id(waermemertrag_electr_ww_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_electr_ww_total_mWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_ww_tag_kwh received over can is %f", id(waermemertrag_electr_ww_total_mWh));}
              else if(x[4]==0x29){
                id(waermemertrag_electr_heiz_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_electr_heiz_total_mWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_heiz_tag_kwh received over can is %f", id(waermemertrag_electr_heiz_total_mWh));}
              else if(x[4]==0x2b){
              id(waermemertrag_ww_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
              id(waermemertrag_ww_tag_kwh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_tag_kwh received over can is %f", id(waermemertrag_ww_tag_kwh));}
              else if(x[4]==0x2d){
              id(waermemertrag_ww_total_mWh) =float(int((x[6])+( (x[5])<<8)));
              id(waermemertrag_ww_total_mWh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_total_mWh received over can is %f", id(waermemertrag_ww_total_mWh));}
              else if(x[4]==0x2f){
                id(waermemertrag_heiz_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_heiz_tag_kwh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_tag_kwh received over can is %f", id(waermemertrag_heiz_tag_kwh));}
              else if(x[4]==0x31){
                id(waermemertrag_heiz_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_heiz_total_mWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_total_kWh_float received over can is %f", id(waermemertrag_heiz_total_mWh));}
            }


#WĂ€rmeertrag WW/Heizung Wh / kWH
    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if(x[4]==0x24){
                id(waermemertrag_electr_ww_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_electr_ww_total_kWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_ww_tag_wh_float received over can is %f", id(waermemertrag_electr_ww_total_kWh_float));}
              else if(x[4]==0x28){
                id(waermemertrag_electr_heiz_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_electr_heiz_total_kWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_heiz_tag_wh_float received over can is %f", id(waermemertrag_electr_heiz_total_kWh_float));}
              else if(x[4]==0x2a){
              id(waermemertrag_ww_tag_wh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
              id(waermemertrag_ww_tag_wh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_tag_wh_float received over can is %f", id(waermemertrag_ww_tag_wh_float));}
              else if(x[4]==0x2c){
              id(waermemertrag_ww_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
              id(waermemertrag_ww_total_kWh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_total_kWh_float received over can is %f", id(waermemertrag_ww_total_kWh_float));}
              else if(x[4]==0x2e){
                id(waermemertrag_heiz_tag_wh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_heiz_tag_wh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_tag_wh_float received over can is %f", id(waermemertrag_heiz_tag_wh_float));}
              else if(x[4]==0x30){
                id(waermemertrag_heiz_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_heiz_total_kWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_total_kWh_float received over can is %f", id(waermemertrag_heiz_total_kWh_float));}
            }

Do you have any suggestions on what to do next ?

Many thanks

Hi Bart,
in the log file I don’t see that you send a request.
That would look something like this:
[00:05:09][D][canbus:032]: send extended id=0x680 size=7
So it seems to me that you only see the regular communication between the heat pump and the display.
180 being the heat pump and I have no idea what the 480 is.
What I did to make it work (for me) is the following:
I took something where I know the value and which is displayed on first page of my heat pump display. For me this was Außentemperatur.
Then I verified the id of Außentemperatur by removing the if check for x0 and x1.
Then I tried sending with different can ids.
For me (LWZ 5S Trend) the 6a2 worked nicely.

Hi Bart,

as RedAnt79 mentioned, your log doesn’t look if any request was sent from your component.
If you used my last config from September 21st, make sure that you give it some time, as the values only update every few minutes.

e.g. the sensor “Außentemperatur” has an update_interval of 10 minutes.
If you want them to update more often, you can either reduce the time in update_interval, or you create a script in home assistant as I did it, to force an update by pushing a button.

2022-11-09 21_24_45-Configured my ESPHome with MCP2515 CAN-Bus for Stiebel Eltron heating pump - Sha

@Sab3rRid3r
Here is the script I currently use for preparing the warm water. For sure it can be improved.
In the heat-pump I’ve set a time-program, that switches to comfort-temperature during the day, and eco at night. You could also leave it at comfort-temperature over the whole day since I only change the comfort-temperature. But I like it to have some failure mode protection if something goes wrong with home assistant.
I also have a towel-heater in the bathroom, which I only turn on if there is enough power available. That’s why I distinguish some values with around 650 Watts difference.

alias: A_WW_Warmwasseraufbereitung
description: Warmwasseraufbereitung je nach PV-Strom
trigger:
  - platform: numeric_state
    entity_id: sensor.power_real_fronius_meter_0_192_168_1_16
    for:
      hours: 0
      minutes: 8
      seconds: 0
    below: -2700
    id: genug_PVStrom
  - platform: numeric_state
    entity_id: sensor.power_real_fronius_meter_0_192_168_1_16
    for:
      hours: 0
      minutes: 8
      seconds: 0
    below: -2050
    id: ausreichend_PVStrom
  - platform: numeric_state
    entity_id: sensor.power_real_fronius_meter_0_192_168_1_16
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: 50
    id: zu_wenig_PVStrom
  - platform: numeric_state
    entity_id: sensor.wt_dammerung_lx
    for:
      hours: 0
      minutes: 1
      seconds: 0
    below: 20
    id: Sonnenuntergang
  - platform: template
    value_template: >-
      {{as_timestamp(utcnow())|float >=
      as_timestamp(states("sensor.power_highest_peak_time_today"))|float}}
    id: highest_estimated_peak_time_erreicht
condition: []
action:
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id: genug_PVStrom
          - condition: numeric_state
            entity_id: sensor.speicher_ist_temperatur
            below: 54
    then:
      - service: input_text.set_value
        data:
          value: "{{ 580|int }}"
        target:
          entity_id: input_text.ww_komfort_temp
    else:
      - if:
          - condition: and
            conditions:
              - condition: trigger
                id: ausreichend_PVStrom
              - condition: numeric_state
                entity_id: sensor.speicher_ist_temperatur
                below: 48
              - condition: numeric_state
                entity_id: input_text.ww_komfort_temp
                below: 500
        then:
          - service: input_text.set_value
            data:
              value: "{{ 500|int }}"
            target:
              entity_id: input_text.ww_komfort_temp
        else:
          - if:
              - condition: and
                conditions:
                  - condition: trigger
                    id: highest_estimated_peak_time_erreicht
                  - condition: numeric_state
                    entity_id: input_text.ww_komfort_temp
                    below: 450
                  - condition: numeric_state
                    entity_id: sensor.speicher_ist_temperatur
                    below: 400
                  - condition: template
                    value_template: >
                      {{states("sensor.energy_production_today")|float >=
                      states("sensor.energy_production_tomorrow")|float*1.7}}
            then:
              - service: input_text.set_value
                data:
                  value: "{{ 450|int }}"
                target:
                  entity_id: input_text.ww_komfort_temp
            else:
              - if:
                  - condition: and
                    conditions:
                      - condition: trigger
                        id: zu_wenig_PVStrom
                      - condition: numeric_state
                        entity_id: input_text.ww_komfort_temp
                        above: 400
                then:
                  - service: input_text.set_value
                    data:
                      value: "{{ 380|int }}"
                    target:
                      entity_id: input_text.ww_komfort_temp
                else:
                  - if:
                      - condition: and
                        conditions:
                          - condition: trigger
                            id: Sonnenuntergang
                          - condition: numeric_state
                            entity_id: input_text.ww_komfort_temp
                            above: 380
                    then:
                      - service: input_text.set_value
                        data:
                          value: "{{ 380|int }}"
                        target:
                          entity_id: input_text.ww_komfort_temp
mode: queued
trace:
  stored_traces: 20

Hey @RedAnt79 and @roberreiter,

Thank you for all your help.

There were couple of issues with my setup.

First of all I have HM Trend (WPM4) it has 2 CAN A and 2 CAN B ports, CAN A ports are used to connect wpm4 to the heat pump mfg etc and the CAN B ports are for ISG, FET and a like. Initially I’ve been connecting to CAN A ports because these were the only ports that returned some data to the ESP but that setup was troublesome since pump was displaying issues about (interrupted or missing communications between components) so definitely a “no go” there, CAN B ports where not returning any data
 after a while I’ve found that CAN A ports are running on 20kbps and CAN B are running on 50kbps, so after changing config in ESP home I finally am getting the data from the heat pump.

Second thing was that not all requests where being accepted when can_id was set to 680, mainly Power consumption and Heat generated were missing so I ended up using can_id: 4 for the mcp2515, but the requests that are send are still send with can_id: 680

Third, the power consumption and heat is transported over can_id: 514.

So at the moment I am able to change the pump mode (comfort, eco, etc.), get water target and current, power consumption, heat generated, circulating heat in the underfloor heating, so, so far so good.

There are still things missing like the FES not answering the temperature or humidity so I guess I have to find correct can_id, or eco and comfort tank target settings

I am trying to get the missing values to show up although I’ve got most of the values that I really cared about.
Now what I need to figure out is how to change comfort and eco heating temperature, it would be great to be able to set that and connect to my Heatmiser unit and set the temperature from there
 :slight_smile:

Thank you for all your help and great work! :100:

1 Like

If anyone is interested that’s what I’ve got up and running for last couple of days: :arrow_down:

globals:
#Variablen fĂŒr Wirkungsgrad der WĂ€rmepumpe

  - id: VD_starts_h
    type: int
    initial_value: '0'
    restore_value: no

  - id: VD_starts_t
    initial_value: '0'
    type: float
    restore_value: no

  - id: ww_cop_float
    type: float
    restore_value: no
  - id: ww_cop_ertrag_electr_flag
    type: bool
    restore_value: no
  - id: ww_cop_ertrag_flag
    type: bool
    restore_value: no
  - id: ww_cop_electr_leistung_flag
    type: bool
    restore_value: no
  
  - id: heat_cop_float
    type: float
    restore_value: no
  - id: heat_cop_ertrag_electr_flag
    type: bool
    restore_value: no
  - id: heat_cop_ertrag_flag
    type: bool
    restore_value: no
  - id: heat_cop_electr_leistung_flag
    type: bool
    restore_value: no

  - id: heat_cop_flag
    type: bool
    restore_value: no
  - id: ww_cop_flag
    type: bool
    restore_value: no
  - id: total_cop_float
    type: float
    restore_value: no

##Variablen fĂŒr Senden von CAN-Bus Befehlen aus Eingabefeldern (fĂŒr Debuggin-Zwecke)
#  - id: val0
#    type: int
#    restore_value: no
#  - id: val1
#    type: int
#    restore_value: no
#  - id: val2
#    type: int
#    restore_value: no
#  - id: val3
#    type: int
#    restore_value: no
#  - id: val4
#    type: int
#    restore_value: no
#  - id: val5
#    type: int
#    restore_value: no
#  - id: val6
#    type: int
#    restore_value: no

#Arrays zum Senden von Can-Bus Befehlen aus Programmcode


  - id: ww_temp_komfort
    type: int[7]
    #Vorbelegung zum Senden an CAN-Adresse 480
    initial_value: '{0x30,0x00,0x13,0x00,0x00,0x00,0x00}'
    restore_value: no
  - id: ww_temp_eco
    type: int[7]
    initial_value: '{0x30,0x00,0xfa,0x0a,0x06,0x00,0x00}'
    restore_value: no


#Variablen fĂŒr senden von CAN-Bus Befehlen zum Umschalten auf Warmwasserbetrieb (evtl. ersetzen durch Array)
  - id: dataframe0
    type: int
    restore_value: no
  - id: dataframe1
    type: int
    restore_value: no
  - id: dataframe2
    type: int
    restore_value: no
  - id: dataframe3
    type: int
    restore_value: no
  - id: dataframe4
    type: int
    restore_value: no
  - id: dataframe5
    type: int
    restore_value: no
  - id: dataframe6
    type: int
    restore_value: no
    
    
#Variablen fĂŒr Leistungsaufnahme und Flags zur programminternen Berechnung    
  - id: el_aufnahmeleistung_ww_tag_wh_float
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_ww_tag_wh_flag
    type: bool
    restore_value: no
  - id: el_aufnahmeleistung_ww_tag_kwh
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_ww_tag_kwh_flag
    type: bool
    restore_value: no
  - id: el_aufnahmeleistung_heiz_tag_wh_float
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_heiz_tag_wh_flag
    type: bool
    restore_value: no
  - id: el_aufnahmeleistung_heiz_tag_kwh
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_heiz_tag_kwh_flag
    type: bool
    restore_value: no 
  - id: el_aufnahmeleistung_ww_total_kWh_float
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_ww_total_kWh_flag
    type: bool
    restore_value: no
  - id: el_aufnahmeleistung_ww_total_mWh
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_ww_total_mWh_flag
    type: bool
    restore_value: no
  - id: el_aufnahmeleistung_heiz_total_kWh_float
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_heiz_total_kWh_flag
    type: bool
    restore_value: no
  - id: el_aufnahmeleistung_heiz_total_mWh
    type: float
    restore_value: no
  - id: el_aufnahmeleistung_heiz_total_mWh_flag
    type: bool
    restore_value: no


  - id: waermemertrag_ww_tag_wh_float
    type: float
    restore_value: no
  - id: waermemertrag_ww_tag_wh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_ww_tag_kwh
    type: float
    restore_value: no
  - id: waermemertrag_ww_tag_kwh_flag
    type: bool
    
  - id: waermemertrag_electr_ww_tag_wh_float
    type: float
    restore_value: no
  - id: waermemertrag_electr_ww_tag_wh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_electr_ww_tag_kwh
    type: float
    restore_value: no
  - id: waermemertrag_electr_ww_tag_kwh_flag
    type: bool    
    restore_value: no

  - id: waermemertrag_heiz_tag_wh_float
    type: float
    restore_value: no
  - id: waermemertrag_heiz_tag_wh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_heiz_tag_kwh
    type: float
    restore_value: no
  - id: waermemertrag_heiz_tag_kwh_flag
    type: bool
    restore_value: no 

  - id: waermemertrag_electr_heiz_tag_wh_float
    type: float
    restore_value: no
  - id: waermemertrag_electr_heiz_tag_wh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_electr_heiz_tag_kwh
    type: float
    restore_value: no
  - id: waermemertrag_electr_heiz_tag_kwh_flag
    type: bool
    restore_value: no 

  - id: waermemertrag_ww_total_kWh_float
    type: float
    restore_value: no
  - id: waermemertrag_ww_total_kWh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_ww_total_mWh
    type: float
    restore_value: no
  - id: waermemertrag_ww_total_mWh_flag
    type: bool
    restore_value: no

  - id: waermemertrag_heiz_total_kWh_float
    type: float
    restore_value: no
  - id: waermemertrag_heiz_total_kWh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_heiz_total_mWh
    type: float
    restore_value: no
  - id: waermemertrag_heiz_total_mWh_flag
    type: bool
    restore_value: no

  - id: waermemertrag_electr_heiz_total_kWh_float
    type: float
    restore_value: no
  - id: waermemertrag_electr_heiz_total_kWh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_electr_heiz_total_mWh
    type: float
    restore_value: no
  - id: waermemertrag_electr_heiz_total_mWh_flag
    type: bool
    restore_value: no

  - id: waermemertrag_electr_ww_total_kWh_float
    type: float
    restore_value: no
  - id: waermemertrag_electr_ww_total_kWh_flag
    type: bool
    restore_value: no
  - id: waermemertrag_electr_ww_total_mWh
    type: float
    restore_value: no
  - id: waermemertrag_electr_ww_total_mWh_flag
    type: bool
    restore_value: no


#Sensorabschnitt
sensor:
  - platform: template
    name: "Outside temperature"
    id: temperature_outside
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-lines"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Source temperature"
    id: temperature_source
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-lines"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Hot water temperature"
    id: temperature_water
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-lines"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Program start"
    id: ww_start
    icon: "mdi:timer-play"
    state_class: "measurement"
    accuracy_decimals: 0

  - platform: template
    name: "Program end"
    id: ww_ende
    icon: "mdi:timer-stop"
    state_class: "measurement"
    accuracy_decimals: 0

  - platform: template
    name: "COP value heating"
    id: cop_heater
    unit_of_measurement: "a.u."
    icon: "mdi:chart-bell-curve-cumulative"
    device_class: "power_factor"
    state_class: "measurement"
    accuracy_decimals: 2

  - platform: template
    name: "COP value hot water"
    id: cop_water
    unit_of_measurement: "a.u."
    icon: "mdi:chart-bell-curve-cumulative"
    device_class: "power_factor"
    state_class: "measurement"
    accuracy_decimals: 2

  - platform: template
    name: "Total COP value"
    id: cop_total
    unit_of_measurement: "a.u."
    icon: "mdi:chart-bell-curve-cumulative"
    device_class: "power_factor"
    state_class: "measurement"
    accuracy_decimals: 2

  - platform: template
    name: "Return temperature heating"
    id: temperature_return
    unit_of_measurement: "°C"
    icon: "mdi:waves-arrow-left"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1
    
  - platform: template
    name: "Heating temperature circuit ACTUAL"
    id: t_heizkreis_ist
    unit_of_measurement: "°C"
    icon: "mdi:waves-arrow-right"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1
    
  - platform: template
    name: "Heating temperature circuit target"
    id: t_heizkreis_soll
    unit_of_measurement: "°C"
    icon: "mdi:waves-arrow-left"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Storage target temperature"
    id: t_ww_soll
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-water"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1


  - platform: template
    name: "Storage temperature"
    id: t_ww_ist
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-lines"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Eco storage target temperature"
    id: ww_temp_eco_log
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-low"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Comfort tank target temperature"
    id: ww_temp_komfort_log
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-high"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1



  - platform: template
    name: "Humidity inside"
    id: humidity_inside
    unit_of_measurement: "%rH"
    icon: "mdi:water-percent"
    device_class: "humidity"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Temperature living room"
    id: temperature_inside
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-lines"
    device_class: "temperature"
    state_class: "measurement"
    accuracy_decimals: 1

  - platform: template
    name: "Electricity consumption hot water today"
    id: daily_electric_energy_water
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: "measurement"
    accuracy_decimals: 3
    icon: "mdi:transmission-tower"

  - platform: template
    name: "Electricity consumption heating today"
    id: daily_electric_energy_heating
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: "measurement"
    icon: "mdi:transmission-tower"
    accuracy_decimals: 3   

  - platform: template
    name: "Total consumption of hot water"
    id: total_electric_energy_water
    unit_of_measurement: "MWh"
    device_class: "energy"
    state_class: "measurement"
    icon: "mdi:transmission-tower"
    accuracy_decimals: 3

  - platform: template
    name: "Electricity consumption heating total"
    id: total_electric_energy_heating
    unit_of_measurement: "MWh"
    device_class: "energy"
    icon: "mdi:transmission-tower"
    state_class: "measurement"
    accuracy_decimals: 3

  - platform: template
    name: "Energy eating today"
    id: daily_heating_energy
    unit_of_measurement: "kWh"
    device_class: "energy"
    icon: "mdi:water-boiler"
    state_class: "measurement"
    accuracy_decimals: 3
   
  - platform: template
    name: "Energy heating total"
    id: total_heating_energy
    unit_of_measurement: "MWh"
    device_class: "energy"
    icon: "mdi:water-boiler"
    state_class: "measurement"
    accuracy_decimals: 3

  - platform: template
    name: "WM hot water today"
    id: daily_heating_energy_water
    unit_of_measurement: "kWh"
    device_class: "energy"
    icon: "mdi:water-boiler"
    state_class: "measurement"
    accuracy_decimals: 3

  - platform: template
    name: "WM hot water total"
    id: total_heating_energy_water
    unit_of_measurement: "MWh"
    device_class: "energy"
    icon: "mdi:water-boiler"
    state_class: "measurement"
    accuracy_decimals: 3

    
  - platform: template
    name: "WM electr. Total hot water"
    id: total_electric_heating_energy_water
    unit_of_measurement: "kWh"
    device_class: "energy"
    icon: "mdi:water-boiler"
    state_class: "measurement"
    accuracy_decimals: 3


  - platform: template
    name: "WM electr. totally heat"
    id: total_electric_heating_energy
    unit_of_measurement: "kWh"
    device_class: "energy"
    icon: "mdi:water-boiler"
    state_class: "measurement"
    accuracy_decimals: 3


#Auswahlfeld zum Umschalten der Betriebsmodi
select:
  - platform: template
    name: "hot water operation"
    id: wasserbetrieb
    optimistic: true
    options:
      - Notbetrieb
      - Bereitschaft
      - Automatik
      - Komfort
      - Eco
      - Warmwasserbetrieb
    initial_option: Automatik
    on_value:
      then:
        - lambda: |-
            id(dataframe0)=0x30;
            id(dataframe1)=0x00;
            id(dataframe2)=0xfa;
            id(dataframe3)=0x01;
            id(dataframe4)=0x12;
            id(dataframe6)=0x00;
            if (x=="Automatik"){
              id(dataframe5)=0x02;
            }
            else if (x=="Komfort"){
              id(dataframe5)=0x03;
            }
            else if (x=="Eco"){
              id(dataframe5)=0x04;
            }
            else if (x=="Warmwasserbetrieb"){
              id(dataframe5)=0x05;
            }
            else if (x=="Bereitschaft"){
              id(dataframe5)=0x01;
            }
            else if (x=="Notbetrieb"){
              id(dataframe5)=0x00;
            }
            ESP_LOGD("main", "The current value of hot water operation is %x", id(dataframe5));

#Einstellung Solltemp Eco: 0a06
#Einstellung Solltemp Komfort: 0013


button:
  - platform: template
    name: Switch hot water mode
    id: warmwasserbetrieb_umschalten
    on_press:
      then:
        - canbus.send: 
            data: !lambda
              return {(uint8_t) id(dataframe0),(uint8_t) id(dataframe1),(uint8_t) id(dataframe2),(uint8_t) id(dataframe3), (uint8_t) id(dataframe4),(uint8_t) id(dataframe5),(uint8_t) id(dataframe6)};
            can_id: 0x680


switch:
##Restart-sw um tÀglichen Restart von ESP-Device via Homeassistant zu initiieren (Ausfallsicherheit)
  - platform: restart
    name: "Boiler room ESP restart"

binary_sensor:
  - platform: template
    name: "EVU Sperre"
    id: "evu_lock"

#Timer - alle 10 Minuten auslösen
time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
     
      - seconds: 10
        then:
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x1c,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x1d,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x20,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x21,0x00,0x00 ]
              can_id: 0x680
          - delay: 10s
          - lambda: |- 
              if (id(el_aufnahmeleistung_ww_total_mWh_flag) and id(el_aufnahmeleistung_ww_total_kWh_flag)){
              id(el_aufnahmeleistung_ww_total_mWh) += id(el_aufnahmeleistung_ww_total_kWh_float);
              id(total_electric_energy_water).publish_state(id(el_aufnahmeleistung_ww_total_mWh));
              };
              id(el_aufnahmeleistung_ww_total_mWh_flag)=false;
              id(el_aufnahmeleistung_ww_total_kWh_flag)=false;
          - lambda: |- 
              if (id(el_aufnahmeleistung_heiz_total_mWh_flag) and id(el_aufnahmeleistung_heiz_total_kWh_flag)){
              id(el_aufnahmeleistung_heiz_total_mWh) += id(el_aufnahmeleistung_heiz_total_kWh_float);
              id(total_electric_energy_heating).publish_state(id(el_aufnahmeleistung_heiz_total_mWh));
              };
              id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;
              id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;        

          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x1b,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x1a,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x1e,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x09,0x1f,0x00,0x00 ]
              can_id: 0x680
          - delay: 10s
          - lambda: |- 
              if (id(el_aufnahmeleistung_ww_tag_kwh_flag) and id(el_aufnahmeleistung_ww_tag_wh_flag)){
              id(el_aufnahmeleistung_ww_tag_kwh) += id(el_aufnahmeleistung_ww_tag_wh_float);
              id(daily_electric_energy_water).publish_state(id(el_aufnahmeleistung_ww_tag_kwh));
              };
              id(el_aufnahmeleistung_ww_tag_kwh_flag)=false;
              id(el_aufnahmeleistung_ww_tag_wh_flag)=false;
          - lambda: |- 
              if (id(el_aufnahmeleistung_heiz_tag_kwh_flag) and id(el_aufnahmeleistung_heiz_tag_wh_flag)){
              id(el_aufnahmeleistung_heiz_tag_kwh) += id(el_aufnahmeleistung_heiz_tag_wh_float);
              id(daily_electric_energy_heating).publish_state(id(el_aufnahmeleistung_heiz_tag_kwh));
              };
              id(el_aufnahmeleistung_heiz_tag_kwh_flag)=false;
              id(el_aufnahmeleistung_heiz_tag_wh_flag)=false;
          - canbus.send:
              data: [ 0xa1, 0x14, 0xfa,0x00,0x74,0x00,0x00 ]
              can_id: 0x680
          - lambda: |-
              ESP_LOGD("main", "EVU Sperre requested");

#WM NE WW Summe wh  - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x22,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
#WM NE WW Summe kwh  - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x23,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms


#WM NE Heizen Summe wh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x26,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
#WM NE Heizen Summe kwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x27,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms


#WM WW Tag wh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x2a,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms

#WM WW Tag kwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x2b,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
#WM WW Summe kwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x2c,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms

#WM WW Summe Mwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x2d,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms

#WM Heizen Tag wh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x2e,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms

#WM Heizen Tag kwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x2f,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms

#WM Heizen Summe kwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x30,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
#WM Heizen Summe Mwh - ok
          - canbus.send:
              data: [ 0xA1, 0x14, 0xfa,0x09,0x31,0x00,0x00 ]
              can_id: 0x680
          - delay: 10s


#WW_Programm
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x17,0xa0,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

          #WM NE WW Summe wh  - ok
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x22,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
#WM NE WW Summe kwh  - ok
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x23,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms


#WM NE Heizen Summe wh - ok
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x26,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms
#WM NE Heizen Summe kwh - ok
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x27,0x00,0x00 ]
              can_id: 0x680
          - delay: 200ms

#WM NE WW Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x24,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM NE WW Summe mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x25,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#WM NE Heizen Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x28,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM NE Heizen Summe mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x29,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#WM WW Tag wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2a,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM WW Tag kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2b,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM WW Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2c,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM WW Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2d,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM Heizen Tag wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2e,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM Heizen Tag kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x2f,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WM Heizen Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x30,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#WM Heizen Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x31,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#el. Leistungsaufnahme WW Tag Wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1a,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme WW Tag kWh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1b,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#el. Leistungsaufnahme WW Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1c,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme WW Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1d,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#el. Leistungsaufnahme Heizen Tag Wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1e,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme Heizen Tag Wh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x1f,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


#el. Leistungsaufnahme Heizen Summe kwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x20,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms
#el. Leistungsaufnahme Heizen Summe Mwh
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x09,0x21,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms


          - lambda: |-
              if (id(waermemertrag_electr_ww_total_mWh_flag) and id(waermemertrag_electr_ww_total_kWh_flag)){
              id(waermemertrag_electr_ww_total_mWh) += id(waermemertrag_electr_ww_total_kWh_float);
              id(total_electric_heating_energy_water).publish_state(id(waermemertrag_electr_ww_total_mWh));
              id(ww_cop_ertrag_electr_flag)=true;
              };
              id(waermemertrag_electr_ww_total_mWh_flag)=false;
              id(waermemertrag_electr_ww_total_kWh_flag)=false;


          - lambda: |-
              if (id(waermemertrag_electr_heiz_total_kWh_flag) and id(waermemertrag_electr_heiz_total_mWh_flag)){
              id(waermemertrag_electr_heiz_total_mWh) += id(waermemertrag_electr_heiz_total_kWh_float);
              id(total_electric_heating_energy).publish_state(id(waermemertrag_electr_heiz_total_mWh));
              id(heat_cop_ertrag_electr_flag)=true;
              };
              id(waermemertrag_electr_heiz_total_kWh_flag)=false;
              id(waermemertrag_electr_heiz_total_mWh_flag)=false;
       

          - lambda: |-
              if (id(waermemertrag_ww_total_mWh_flag) and id(waermemertrag_ww_total_kWh_flag)){
              id(waermemertrag_ww_total_mWh) += id(waermemertrag_ww_total_kWh_float);
              id(total_heating_energy_water).publish_state(id(waermemertrag_ww_total_mWh));
              id(ww_cop_ertrag_flag)=true;
              };
              id(waermemertrag_ww_total_mWh_flag)=false;
              id(waermemertrag_ww_total_kWh_flag)=false;

          - lambda: |-
              if (id(waermemertrag_heiz_total_kWh_flag) and id(waermemertrag_heiz_total_mWh_flag)){
              id(waermemertrag_heiz_total_mWh) += id(waermemertrag_heiz_total_kWh_float);
              id(total_heating_energy).publish_state(id(waermemertrag_heiz_total_mWh));
              id(heat_cop_ertrag_flag)=true;
              };
              id(waermemertrag_heiz_total_kWh_flag)=false;
              id(waermemertrag_heiz_total_mWh_flag)=false;
       
          - lambda: |-
              if (id(waermemertrag_heiz_tag_kwh_flag) and id(waermemertrag_heiz_tag_wh_flag)){
              id(waermemertrag_heiz_tag_kwh) += id(waermemertrag_heiz_tag_wh_float);
              id(daily_heating_energy).publish_state(id(waermemertrag_heiz_tag_kwh));
              };
              id(waermemertrag_heiz_tag_kwh_flag)=false;
              id(waermemertrag_heiz_tag_wh_flag)=false;

          - lambda: |-
              if (id(waermemertrag_ww_tag_kwh_flag) and id(waermemertrag_ww_tag_wh_flag)){
              id(waermemertrag_ww_tag_kwh) += id(waermemertrag_ww_tag_wh_float);
              id(daily_heating_energy_water).publish_state(id(waermemertrag_ww_tag_kwh));
              };
              id(waermemertrag_ww_tag_kwh_flag)=false;
              id(waermemertrag_ww_tag_wh_flag)=false;



          - lambda: |-
              if (id(el_aufnahmeleistung_ww_total_mWh_flag) and id(el_aufnahmeleistung_ww_total_kWh_flag)){
              id(el_aufnahmeleistung_ww_total_mWh) += id(el_aufnahmeleistung_ww_total_kWh_float);
              id(total_electric_energy_water).publish_state(id(el_aufnahmeleistung_ww_total_mWh));
              id(ww_cop_electr_leistung_flag)=true;
              };
              id(el_aufnahmeleistung_ww_total_mWh_flag)=false;
              id(el_aufnahmeleistung_ww_total_kWh_flag)=false;

          - lambda: |-
              if (id(el_aufnahmeleistung_heiz_total_mWh_flag) and id(el_aufnahmeleistung_heiz_total_kWh_flag)){
              id(el_aufnahmeleistung_heiz_total_mWh) += id(el_aufnahmeleistung_heiz_total_kWh_float);
              id(total_electric_energy_heating).publish_state(id(el_aufnahmeleistung_heiz_total_mWh));
              id(heat_cop_electr_leistung_flag)=true;
              };
              id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;
              id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;       

          - lambda: |-
              if (id(el_aufnahmeleistung_ww_tag_kwh_flag) and id(el_aufnahmeleistung_ww_tag_wh_flag)){
              id(el_aufnahmeleistung_ww_tag_kwh) += id(el_aufnahmeleistung_ww_tag_wh_float);
              id(daily_electric_energy_water).publish_state(id(el_aufnahmeleistung_ww_tag_kwh));
              };
              id(el_aufnahmeleistung_ww_tag_kwh_flag)=false;
              id(el_aufnahmeleistung_ww_tag_wh_flag)=false;

          - lambda: |-
              if (id(el_aufnahmeleistung_heiz_tag_kwh_flag) and id(el_aufnahmeleistung_heiz_tag_wh_flag)){
              id(el_aufnahmeleistung_heiz_tag_kwh) += id(el_aufnahmeleistung_heiz_tag_wh_float);
              id(daily_electric_energy_heating).publish_state(id(el_aufnahmeleistung_heiz_tag_kwh));
              };
              id(el_aufnahmeleistung_heiz_tag_kwh_flag)=false;
              id(el_aufnahmeleistung_heiz_tag_wh_flag)=false;

#Berechnung Coefficient of Performance (COP)
          - lambda: |-
              if (id(ww_cop_ertrag_electr_flag) and id(ww_cop_ertrag_flag) and id(ww_cop_electr_leistung_flag)){
              id(ww_cop_float) = (id(waermemertrag_ww_total_mWh)+id(waermemertrag_electr_ww_total_mWh))/id(el_aufnahmeleistung_ww_total_mWh);
              id(cop_water).publish_state(id(ww_cop_float));
              id(ww_cop_flag)=true;
              };
              id(ww_cop_ertrag_electr_flag)=false;
              id(ww_cop_ertrag_flag)=false;
              id(ww_cop_electr_leistung_flag)=false;

          - lambda: |-
              if (id(heat_cop_ertrag_electr_flag) and id(heat_cop_ertrag_flag) and id(heat_cop_electr_leistung_flag)){
              id(heat_cop_float) = (id(waermemertrag_heiz_total_mWh)+id(waermemertrag_electr_heiz_total_mWh))/id(el_aufnahmeleistung_heiz_total_mWh);
              id(cop_heater).publish_state(id(heat_cop_float));
              id(heat_cop_flag)=true;
              };
              id(heat_cop_ertrag_electr_flag)=false;
              id(heat_cop_ertrag_flag)=false;
              id(heat_cop_electr_leistung_flag)=false;

          - lambda: |-
              if (id(heat_cop_flag) and id(ww_cop_flag)){
              id(total_cop_float) = ((id(waermemertrag_heiz_total_mWh)+id(waermemertrag_electr_heiz_total_mWh))+(id(waermemertrag_ww_total_mWh)+id(waermemertrag_electr_ww_total_mWh)))/(id(el_aufnahmeleistung_heiz_total_mWh)+id(el_aufnahmeleistung_ww_total_mWh));
              id(cop_total).publish_state(id(total_cop_float));
              };
              id(heat_cop_flag)=false;
              id(ww_cop_flag)=false;

#Außentemperatur 1/10 °C et dec value
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x00,0x0c,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WW Speicher IST
          - canbus.send:
              data: [ 0x31, 0x00, 0x0e,0x00,0x00,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 


#RĂŒcklauftemperatur Hzg - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x00,0x16,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 

#WW Soll-Temperatur
          - canbus.send:
              data: [ 0x31, 0x00, 0x03,0x00,0x00,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 

#Quelle IST: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x01,0xd4,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 

          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x02,0x65,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#T_Heizkreis_IST Abfrage: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x02,0xca,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 
#T_Heizkreis_Soll Abfrage: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x01,0xd7,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms 

#Warmwasser Betriebsmodus Abfrage: - 1/10
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x01,0x12,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WW Eco Soll Abfrage
          - canbus.send:
              data: [ 0x31, 0x00, 0xfa,0x0a,0x06,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

#WW Komfort Soll Abfrage
          - canbus.send:
              data: [ 0x31, 0x00, 0x13,0x00,0x00,0x00,0x00 ]
              can_id: 0x680
          - delay: 500ms

spi:
  id: McpSpi
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

canbus:
  - platform: mcp2515
    id: my_mcp2515
    spi_id: McpSpi
    cs_pin: GPIO17
    can_id: 4
    use_extended_id: false
    bit_rate: 50kbps
    on_frame:

    - can_id: 0x514
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if(x[4]==0x1b){
              id(el_aufnahmeleistung_ww_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
              id(el_aufnahmeleistung_ww_tag_kwh_flag)=true;
              ESP_LOGD("main", "el_aufnahmeleistung_ww_tag_kwh received over can is %f", id(el_aufnahmeleistung_ww_tag_kwh));}
              else if(x[4]==0x1f){
                id(el_aufnahmeleistung_heiz_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
                id(el_aufnahmeleistung_heiz_tag_kwh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_tag_kwh received over can is %f", id(el_aufnahmeleistung_heiz_tag_kwh));}
              else if(x[4]==0x1d){
              id(el_aufnahmeleistung_ww_total_mWh) =float(int((x[6])+( (x[5])<<8)));
              id(el_aufnahmeleistung_ww_total_mWh_flag)=true;
              ESP_LOGD("main", "el_aufnahmeleistung_ww_total_mWh received over can is %f", id(el_aufnahmeleistung_ww_total_mWh));}
              else if(x[4]==0x21){
                id(el_aufnahmeleistung_heiz_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(el_aufnahmeleistung_heiz_total_mWh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_total_mWh received over can is %f", id(el_aufnahmeleistung_heiz_total_mWh));}
            }

    - can_id: 0x514
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if (x[4]==0x1a){
                id(el_aufnahmeleistung_ww_tag_wh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_ww_tag_wh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_ww_tag_kwh received over can is %f", id(el_aufnahmeleistung_ww_tag_wh_float));}
              else if (x[4]==0x1e){
                id(el_aufnahmeleistung_heiz_tag_wh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_heiz_tag_wh_flag) = true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_tag_wh received over can is %f", id(el_aufnahmeleistung_heiz_tag_wh_float));}
              else if (x[4]==0x1c){
                id(el_aufnahmeleistung_ww_total_kWh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_ww_total_kWh_flag)=true;
                ESP_LOGD("main", "el_aufnahmeleistung_ww_total_kkWh received over can is %f", id(el_aufnahmeleistung_ww_total_kWh_float));}
              else if (x[4]==0x20){
                id(el_aufnahmeleistung_heiz_total_kWh_float) = (float((int((x[6])+( (x[5])<<8))))/1000);
                id(el_aufnahmeleistung_heiz_total_kWh_flag) = true;
                ESP_LOGD("main", "el_aufnahmeleistung_heiz_total_kWh received over can is %f", id(el_aufnahmeleistung_heiz_total_kWh_float));}
              }
              if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x00 and x[4]==0x74){
              if(x[5]==0x80 and x[6]==0x00){
                id(evu_lock).publish_state(false);
                }
              else{
                id(evu_lock).publish_state(true);
              };
            };
#WĂ€rmeertrag WW/Heizung MWh / kWH
    - can_id: 0x514
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if(x[4]==0x23){
                id(waermemertrag_electr_ww_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_electr_ww_total_mWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_ww_tag_kwh received over can is %f", id(waermemertrag_electr_ww_total_mWh));}
              else if(x[4]==0x27){
                id(waermemertrag_electr_heiz_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_electr_heiz_total_mWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_heiz_tag_kwh received over can is %f", id(waermemertrag_electr_heiz_total_mWh));}
              else if(x[4]==0x2b){
              id(waermemertrag_ww_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
              id(waermemertrag_ww_tag_kwh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_tag_kwh received over can is %f", id(waermemertrag_ww_tag_kwh));}
              else if(x[4]==0x2d){
              id(waermemertrag_ww_total_mWh) =float(int((x[6])+( (x[5])<<8)));
              id(waermemertrag_ww_total_mWh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_total_mWh received over can is %f", id(waermemertrag_ww_total_mWh));}
              else if(x[4]==0x2f){
                id(waermemertrag_heiz_tag_kwh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_heiz_tag_kwh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_tag_kwh received over can is %f", id(waermemertrag_heiz_tag_kwh));}
              else if(x[4]==0x31){
                id(waermemertrag_heiz_total_mWh) =float(int((x[6])+( (x[5])<<8)));
                id(waermemertrag_heiz_total_mWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_total_kWh_float received over can is %f", id(waermemertrag_heiz_total_mWh));}
            }

#WĂ€rmeertrag WW/Heizung Wh / kWH
    - can_id: 0x514
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x09) {
              if(x[4]==0x22){
                id(waermemertrag_electr_ww_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_electr_ww_total_kWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_ww_tag_wh_float received over can is %f", id(waermemertrag_electr_ww_total_kWh_float));}
              else if(x[4]==0x26){
                id(waermemertrag_electr_heiz_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_electr_heiz_total_kWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_electr_heiz_tag_wh_float received over can is %f", id(waermemertrag_electr_heiz_total_kWh_float));}
              else if(x[4]==0x2a){
              id(waermemertrag_ww_tag_wh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
              id(waermemertrag_ww_tag_wh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_tag_wh_float received over can is %f", id(waermemertrag_ww_tag_wh_float));}
              else if(x[4]==0x2c){
              id(waermemertrag_ww_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
              id(waermemertrag_ww_total_kWh_flag)=true;
              ESP_LOGD("main", "waermemertrag_ww_total_kWh_float received over can is %f", id(waermemertrag_ww_total_kWh_float));}
              else if(x[4]==0x2e){
                id(waermemertrag_heiz_tag_wh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_heiz_tag_wh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_tag_wh_float received over can is %f", id(waermemertrag_heiz_tag_wh_float));}
              else if(x[4]==0x30){
                id(waermemertrag_heiz_total_kWh_float) =float(int((x[6])+( (x[5])<<8)))/1000;
                id(waermemertrag_heiz_total_kWh_flag)=true;
                ESP_LOGD("main", "waermemertrag_heiz_total_kWh_float received over can is %f", id(waermemertrag_heiz_total_kWh_float));}
            } 

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0x13) {
              float temperature =(float((int16_t((x[4])+( (x[3])<<8))))/10);
              id(ww_temp_komfort_log).publish_state(temperature);
              ESP_LOGD("main", "T Comfort Should receiveover can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x0a and x[4]==0x06) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10);
              id(ww_temp_eco_log).publish_state(temperature);
              ESP_LOGD("main", "T Eco target received over can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x02 and x[4] == 0xca) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10);
              id(t_heizkreis_ist).publish_state(temperature);
              ESP_LOGD("main", "T heating circuit ACTUAL received over can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x01 and x[4] == 0xd7) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10);
              id(t_heizkreis_soll).publish_state(temperature);
              ESP_LOGD("main", "T heating circuit target receivedover can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0x03) {
              float temperature =(float((int16_t((x[4])+( (x[3])<<8))))/10);
              id(t_ww_soll).publish_state(temperature);
              ESP_LOGD("main", "T Hot water target received over can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x17 and x[4]==0xa0 ) {
              int start = int(x[5]);
              int ende = int(x[6]);
              id(ww_start).publish_state(start);
              id(ww_ende).publish_state(ende);
              ESP_LOGD("main", "Receive hot water program time start and end over can is %i %i", start, ende);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x01 and x[4]==0x12) {
              if (x[5]==0x00){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Notbetrieb");
                call.perform();}
              else if (x[5]==0x01){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Bereitschaft");
                call.perform();}
              else if (x[5]==0x02){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Automatik");
                call.perform();}
              else if (x[5]==0x03){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Komfort");
                call.perform();}
              else if (x[5]==0x04){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Eco");
                call.perform();}
              else if (x[5]==0x05){
                auto call = id(wasserbetrieb).make_call();
                call.set_option("Warmwasserbetrieb");
                call.perform();}
              }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0e) {
              float temperature =(float((int16_t((x[6])+( (x[5])<<8))))/10)+3.9;
              id(temperature_water).publish_state(temperature);
              ESP_LOGD("main", "Receive hot water temperature over can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x01 and x[4] == 0xd4) {
              float temperature =float((int16_t((x[6])+( (x[5])<<8))))/10;
              id(temperature_source).publish_state(temperature);
              ESP_LOGD("main", "Source Temperature received over can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[2]==0x0e) {
              float temperature =float((int16_t((x[4])+( (x[3])<<8))))/10;
              id(t_ww_ist).publish_state(temperature);
              ESP_LOGD("main", "Storage temperature received over can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x16) {
              float temperature =float((int16_t((x[6])+( (x[5])<<8))))/10;
              id(temperature_return).publish_state(temperature);
              ESP_LOGD("main", "Return temperature receivedover can is %f", temperature);
            }

    - can_id: 0x180
      then:
        - lambda: |-
            if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0c) {
              float temperature =float((int16_t((x[6])+( (x[5])<<8))))/10;
              id(temperature_outside).publish_state(temperature);
              ESP_LOGD("main", "Outside temperature received over can is %f", temperature);
            }

    - can_id: 0x301
      then:
        - lambda: |-
            if(x[0]==0xc0 and x[1]==0x01 and x[2]==0x75) {
              float humidity =float(float((int16_t((x[4])+( (x[3])<<8))))/10);
              id(humidity_inside).publish_state(humidity);
              ESP_LOGD("main", "Humidity received over can is %f", humidity);
            }

    - can_id: 0x301
      then:
        - lambda: |-
            if(x[0]==0xc0 and x[1]==0x01 and x[2]==0x11) {
              float temperature =float((int16_t((x[4])+( (x[3])<<8))))/10;
              id(temperature_inside).publish_state(temperature);
              ESP_LOGD("main", "Room temperature received over can is %f", temperature);
            }
2 Likes

Hey Guys, can anyone please post their pinouts for either the Esp32-wroom and/or Wemos d1 mini?

I have both but I cannot confirm the MCP2515 device works.
Initially I had a raspberry pi zero with a CAN hat, that device works and I see data coming in, using it as a esphome alternative is not possible so I got a MCP2515 but whatever I do nothing is coming in from the Stiebel. When I link the MCP2515 with the RPI also nothing is showing, neither using the D1 nor esp32

I suspect the issue is with the way the MCP2515 is connected to the esp/d1 but I wanted to be sure before I order a new one


Tia

As to “why don’t you use the rpi”?
I cannot get the can_tools to compile, I have been playing with python to receive the messages which works but all the stuff that’s needed to convert the CAN message to something usable is not something I can do without first properly learning python

The esphome route is much easier and is exactly what I’m looking for


Hey @Radiotechniman

I have it setup as follows
VCC → V5
GND → GND
SCK → G18 (GPIO18)
SI → G23 (GPIO23)
SO → G19 (GPIO19)
CS → G17 (GPIO17)

Can id → 4
Bit rate → 50kbps

Thanks @BartekTK, and this is a WROOM?

@Radiotechniman Yes

ESP-32S ESP-WROOM-32

Well that helped a bit, I’m now seeing some response, just not the stuff I’m looking for
Could this be the IDis not correct?

[22:02:57][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[22:02:57][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[22:02:57][D][canbus:067]: received can message (#1) extended can_id=0x5fa13f size=5
[22:02:58][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[22:02:58][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[22:02:59][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[22:02:59][D][canbus:070]: received can message (#1) std can_id=0x0 size=0
[22:02:59][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[22:03:00][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7

Just a quick question,

is it possible to use CAN with Home Assistant on a Raspberry PI with this CAN HAT?

Properties:
Raspberry Pi connectivity, compatible with Raspberry Pi Zero/Zero W/Zero WH/2B/3B/3B+
CAN function, onboard CAN controller MCP2515 via SPI interface, with transceiver SN65HVD230
RS485 function, controlled via UART, half-duplex communication, with transceiver SP3485
Reserved control pins, allows to work with other control boards
Comes with development resources and manual (examples in wiringPi/python)

Specifications

Operating voltage: 3.3V
CAN controller: MCP2515
CAN transceiver: SN65HVD230
485 transceiver: SP3485
Dimension: 65mm x 30mm
Mounting hole size: 3.0mm

Hello, since the outside temperatures go into the negative I get strange values. Looks like 16bit 65536 overflow to me. Do you have any idea how to fix this?

[18:18:28][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[18:18:28][D][canbus:069]: received can message (#1) std can_id=0x180 size=7
[18:18:28][D][sensor:126]: ‘Außentemperatur’: Sending state 6552.60010 °C with 1 decimals of accuracy
[18:18:28][D][main:616]: Temperature received over can is 6552.600098
[18:18:28][D][main:747]: Antwort von 180 Hex: d2 0 fa 0 c ff f6
[18:18:28][D][main:748]: Antwort von 180 Float: 65526.000000
[18:18:28][D][main:749]: Antwort von 180 Dez.: 255 246

#Aussentemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xd2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0c) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_outside).publish_state(temperature);
ESP_LOGD(“main”, “Temperature received over can is %f”, temperature);

Usually you get this kind of answer if you query the wrong idx. E.g. the wrong device where this index is not available. Probably you should try to ask one of the other can addresses in the bus.

The index should be correct I think because when the temperature is positive everything is working like expected. Plz take a look at the pictures. Thanks in advance.



Log from negative temperature degree celsius
[18:18:28][D][sensor:126]: ‘Außentemperatur’: Sending state 6552.60010 °C with 1 decimals of accuracy
[18:18:28][D][main:616]: Temperature received over can is 6552.600098
[18:18:28][D][main:747]: Antwort von 180 Hex: d2 0 fa 0 c ff f6
[18:18:28][D][main:748]: Antwort von 180 Float: 65526.000000
[18:18:28][D][main:749]: Antwort von 180 Dez.: 255 246

Log from positive temperature degree celsius
[14:02:23][D][sensor:126]: ‘Außentemperatur’: Sending state 4.50000 °C with 1 decimals of accuracy
[14:02:23][D][main:616]: Temperature received over can is 4.500000
[14:02:23][D][main:747]: Antwort von 180 Hex: d2 0 fa 0 c 0 2d
[14:02:23][D][main:748]: Antwort von 180 Float: 45.000000
[14:02:23][D][main:749]: Antwort von 180 Dez.: 0 45

Brainstormin, possible solution?
When value > e.g. 65000
256 * 256 = 65536
65536 - value from reading in this case 65526 = 10
10 / 10 *-1 = -0.1 degree celsius

I have the same problem with my LWZ 304 Flex

image

I must admit, now that you’re telling this, I think I had this problem somewhere in the beginning of the year. But temperatures never went below zero since then. Is there a standard way to convert into float with negative sign?
Otherwise I think the solution proposed could work.

I have the same one, it receives the data from the CANbus perfectly but converting that to usable data is where I stopped. As mentioned I tried with the normal tools as with python but ultimately went with a Wemos D1 + Can which works pretty well

1 Like