Correct, I didn’t use any level shifter.
If you have a look at the ESPHome documentation for MCP2515 wiring options, there is an approach with only a resistor in the MISO line.
In my case it works perfectly.
Dear Rober,
Thanks you for your great work and for sharing it with us!
This is a great help for me.
For many years I have been using the “can_scan” toolset from Juerg (http://juerg5524.ch) on a Rasperry Pi 2. This is a bit outdated and now I want to replace it with an ESPHome solution as the data already flows into Home Assistant.
I can adopt your examples in large parts. However, my heat pump does not use the same CAN IDs for all values.
Unfortunately, I don’t quite understand how these addresses are calculated. Would you be so kind as to help me here?
I use the following CAN IDs:
180 (boiler) → 0x31
301 (control unit) → ?
480 (WPM2) → ?
500 (heating module) → ?
601 (mixer module) → ?
CAN-ID 180 is not 0x31 !
for CAN-ID 180 you use the number 3 as the first digit and 0 as the fourth digit.
A request to CAN-ID 180 looks like this:
0x31, 0x00, 0xfa, …
Here is the explanation from juerg5524 to the setup of a telegram:
http://juerg5524.ch/data/Telegramm-Aufbau.txt
for ID 301 you use the digits 6 and 1
For a request to ID 301 the package would start like 0x61, 0x01, 0xFA, …
For 480: 0x91, 0x00, 0xFA, …
500: 0xA1, 0x00, 0xFA, …
601: 0xC1, 0x01, 0xFA, …
If you receive an answer from 180 to your own CAN-ID (assuming you use ID 680 at the controller) you get the second digit set to 2 like so:
0xD2, 0x00, 0xFA, …
If you want to change a value at ID 180, you set the second digit to “2”:
0x32, 0x00, 0xfa, …
Thank you for your explanation and the link to the telegram description.
Now I could understand the format.
I already have the ESP32 here and have programmed it accordingly.
I am just waiting for the CAN bus adapter.
By the way, I use 700 (third-party device) as the CAN bus address. Address 680 is reserved for the Comsoft software. But I guess that doesn’t matter as long as the address is unique.
If everything works and there is interest, I can make my adapted version available here. I have a WPL13 heat pump with WPM2 as manager.
Hi,
You can use another address than 680 of course. Just be sure to change the code for the response packages accordingly.
Of course it would be interesting for me and probably others how this works for you.
After a long wait for the delivery of the CAN bus adapter, I was able to put my prototype into operation today:
My adapted version for a Stiebel Eltron heat pump model WPL 13 with WPM2 control:
esphome:
name: heatpump
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: <your key>
ota:
password: <your password>
wifi:
ssid: <your SSID>
password: <your password>
# Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Head-Pump-Example"
# password: "3af1sfEUCWKI"
#
#captive_portal:
# ESPHome with MCP2515 CAN-Bus for Stiebel Eltron heating pump
# https://community.home-assistant.io/t/configured-my-esphome-with-mcp2515-can-bus-for-stiebel-eltron-heating-pump/366053
# Original by R. Oberreiter (roberreiter)
# Modified for use with WPL13/WPM2 by P.Studer (pst)
globals:
- id: el_aufnahmeleistung_ww_tag_wh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_tag_wh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_ww_tag_kwh
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_tag_kwh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_wh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_wh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_kwh
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_kwh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_ww_total_kWh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_total_kWh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_ww_total_mWh
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_total_mWh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_kWh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_kWh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_mWh
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_ww_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_ww_tag_kwh_flag
type: bool
- id: waermemertrag_electr_ww_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_electr_ww_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_ww_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_electr_ww_tag_kwh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_heiz_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_heiz_tag_kwh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_tag_kwh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_ww_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_total_mWh
type: float
restore_value: yes
- id: waermemertrag_ww_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_heiz_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_total_mWh
type: float
restore_value: yes
- id: waermemertrag_heiz_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_total_mWh
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_ww_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_electr_ww_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_ww_total_mWh
type: float
restore_value: yes
- id: waermemertrag_electr_ww_total_mWh_flag
type: bool
restore_value: yes
sensor:
- platform: template
name: "Außentemperatur"
id: temperature_outside
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Warmwassertemperatur"
id: temperature_water
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Vorlauf Heizung"
id: temperature_forerun
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-right"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Rücklauf Heizung"
id: temperature_return
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-left"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Rücklauf Heizung Soll"
id: temperature_return_setpoint
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-up"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Stromverbrauch Warmwasser heute"
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: "Stromverbrauch Heizung heute"
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: "Stromverbrauch Warmwasser total"
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: "Stromverbrauch Heizung 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: "WM Heizung heute"
id: daily_heating_energy
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "measurement"
accuracy_decimals: 3
- platform: template
name: "WM Heizen 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 Warmwasser heute"
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 Warmwasser 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 elektr. Warmwasser total"
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 elektr. heizen total"
id: total_electric_heating_energy
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "measurement"
accuracy_decimals: 3
binary_sensor:
- platform: template
name: "EVU Sperre"
id: "evu_lock"
time:
- platform: homeassistant
id: homeassistant_time
on_time:
- seconds: /180
then:
#WM NE WW Summe wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x22,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM NE WW Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x23,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM NE Heizen Summe wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x26,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM NE Heizen Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x27,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Tag wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2a,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Tag kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2b,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2c,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2d,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Tag wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2e,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Tag kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2f,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x30,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x31,0x00,0x00 ]
can_id: 0x700
- delay: 10s
- 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(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(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(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(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;
#el. Leistungsaufnahme WW Tag Wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1a,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme WW Tag kWh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1b,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme WW Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1c,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme WW Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1d,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Tag Wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1e,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Tag Wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1f,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x20,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x21,0x00,0x00 ]
can_id: 0x700
- 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;
- 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;
- lambda: |-
ESP_LOGD("main", "EVU Sperre requested");
#Außentemperatur 1/10 °C et dec value - ok /10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x0c,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#Vorlauftemperatur Hzg - ok 1/10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x01,0xd6,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#Rücklauftemperatur Hzg - ok 1/10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x16,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WW Temperatur - ok
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x0e,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#EVU Sperre
- canbus.send:
data: [ 0x91, 0x00, 0xfa,0xfd,0xac,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
spi:
id: McpSpi
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
canbus:
- platform: mcp2515
id: my_mcp2515
spi_id: McpSpi
cs_pin: GPIO15
can_id: 680
use_extended_id: false
bit_rate: 20kbps
on_frame:
#Warmwasser-Temperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0e) {
float temperature =float((float((int((x[6])+( (x[5])<<8))))/10));
id(temperature_water).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Vorlauftemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x01 and x[4] == 0xd6) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_forerun).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Rücklauftemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x16) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_return).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Rücklauftemperaturabfrage Sollwert
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x02) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_return_setpoint).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Außentemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 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);
}
#EVU Lock
- can_id: 0x480
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[2]==0xfa and x[3]==0xfd and x[4] == 0xac) {
if(x[5]==0x80 and x[6]==0x00){
id(evu_lock).publish_state(true);
}
else{
id(evu_lock).publish_state(false);
}
}
#Elektrische Leistungsaufnahme Wh /kWh
- can_id: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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));}
}
#Elektrische Leistungsaufnahme kWh / MWH
- can_id: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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));}
}
#Show data in raw form as hex-values
- can_id: 0x180
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
ESP_LOGD("main", "Antwort von 180 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGD("main", "Antwort von 180 Float: %f", wert7);
ESP_LOGD("main", "Antwort von 180 Dez.: %i %i", wert5, wert6);
Now I will install the prototype in an enclosure and definitely put it into operation.
I can’t see the 4k7 resistor between SDA and MISO port in your configuration.
Keep on sharing your progress…
Well, I don’t need the series resistor in the MISO line because I power the CAN bus module directly with 3.3V. Maybe not quite to specification, but works fine.
This is how my finished circuit board looks.
I have inserted a wideband DC-DC converter in the input so that the heat pump also can provides the power. The WPM2 has an output with ~ 22VDC.
In the code I have changed most of the sensors to the state class “total_ingreasing”. This allows them to be used in the Energy Dashboard. “Last Reset” is no longer supported by Home Assistant.
I have also extended the log and debug function with my additional CAN_IDs.
This morning I put everything into operation and it runs perfectly.
Thinking already about implementing some control functions for the heat pump…
esphome:
name: heatpump
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "<your key>"
ota:
password: "<your key>"
wifi:
ssid: <your SSID>
password: <your key>
# Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Head-Pump-Example"
# password: "<your key>"
#
#captive_portal:
# ESPHome with MCP2515 CAN-Bus for Stiebel Eltron heating pump
# https://community.home-assistant.io/t/configured-my-esphome-with-mcp2515-can-bus-for-stiebel-eltron-heating-pump/366053
# Original by R. Oberreiter (roberreiter)
# Modified for use with WPL13/WPM2 by P.Studer (pst)
globals:
- id: el_aufnahmeleistung_ww_tag_wh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_tag_wh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_ww_tag_kwh
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_tag_kwh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_wh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_wh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_kwh
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_tag_kwh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_ww_total_kWh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_total_kWh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_ww_total_mWh
type: float
restore_value: yes
- id: el_aufnahmeleistung_ww_total_mWh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_kWh_float
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_kWh_flag
type: bool
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_mWh
type: float
restore_value: yes
- id: el_aufnahmeleistung_heiz_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_ww_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_ww_tag_kwh_flag
type: bool
- id: waermemertrag_electr_ww_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_electr_ww_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_ww_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_electr_ww_tag_kwh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_heiz_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_heiz_tag_kwh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_tag_wh_float
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_tag_wh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_tag_kwh
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_tag_kwh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_ww_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_ww_total_mWh
type: float
restore_value: yes
- id: waermemertrag_ww_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_heiz_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_heiz_total_mWh
type: float
restore_value: yes
- id: waermemertrag_heiz_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_heiz_total_mWh
type: float
restore_value: yes
- id: waermemertrag_electr_heiz_total_mWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_ww_total_kWh_float
type: float
restore_value: yes
- id: waermemertrag_electr_ww_total_kWh_flag
type: bool
restore_value: yes
- id: waermemertrag_electr_ww_total_mWh
type: float
restore_value: yes
- id: waermemertrag_electr_ww_total_mWh_flag
type: bool
restore_value: yes
sensor:
- platform: template
name: "Außentemperatur"
id: temperature_outside
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Warmwassertemperatur"
id: temperature_water
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Vorlauf Heizung"
id: temperature_forerun
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-right"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Rücklauf Heizung"
id: temperature_return
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-left"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Rücklauf Heizung Soll"
id: temperature_return_setpoint
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-up"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Stromverbrauch Warmwasser heute"
id: daily_electric_energy_water
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "total_increasing"
accuracy_decimals: 3
icon: "mdi:transmission-tower"
- platform: template
name: "Stromverbrauch Heizung heute"
id: daily_electric_energy_heating
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "total_increasing"
icon: "mdi:transmission-tower"
accuracy_decimals: 3
- platform: template
name: "Stromverbrauch Warmwasser total"
id: total_electric_energy_water
unit_of_measurement: "MWh"
device_class: "energy"
state_class: "total_increasing"
icon: "mdi:transmission-tower"
accuracy_decimals: 3
- platform: template
name: "Stromverbrauch Heizung total"
id: total_electric_energy_heating
unit_of_measurement: "MWh"
device_class: "energy"
icon: "mdi:transmission-tower"
state_class: "total_increasing"
accuracy_decimals: 3
- platform: template
name: "WM Heizung heute"
id: daily_heating_energy
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
- platform: template
name: "WM Heizen total"
id: total_heating_energy
unit_of_measurement: "MWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
- platform: template
name: "WM Warmwasser heute"
id: daily_heating_energy_water
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
- platform: template
name: "WM Warmwasser total"
id: total_heating_energy_water
unit_of_measurement: "MWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
- platform: template
name: "WM elektr. Warmwasser total"
id: total_electric_heating_energy_water
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
- platform: template
name: "WM elektr. heizen total"
id: total_electric_heating_energy
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
binary_sensor:
- platform: template
name: "EVU Sperre"
id: "evu_lock"
time:
- platform: homeassistant
id: homeassistant_time
on_time:
- seconds: /180
then:
#WM NE WW Summe wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x22,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM NE WW Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x23,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM NE Heizen Summe wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x26,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM NE Heizen Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x27,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Tag wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2a,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Tag kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2b,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2c,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM WW Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2d,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Tag wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2e,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Tag kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x2f,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x30,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WM Heizen Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x31,0x00,0x00 ]
can_id: 0x700
- delay: 10s
- 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(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(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(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(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;
#el. Leistungsaufnahme WW Tag Wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1a,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme WW Tag kWh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1b,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme WW Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1c,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme WW Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1d,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Tag Wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1e,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Tag Wh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x1f,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Summe kwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x20,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#el. Leistungsaufnahme Heizen Summe Mwh - ok
- canbus.send:
data: [ 0xA1, 0x00, 0xfa,0x09,0x21,0x00,0x00 ]
can_id: 0x700
- 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;
- 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;
#Außentemperatur 1/10 °C et dec value - ok /10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x0c,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#Vorlauftemperatur Hzg - ok 1/10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x01,0xd6,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#Rücklauftemperatur Hzg - ok 1/10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x16,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#Rücklauftemperatur Hzg Soll - ok 1/10
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x02,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#WW Temperatur - ok
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x00,0x0e,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
#EVU Sperre
- canbus.send:
data: [ 0x91, 0x00, 0xfa,0xfd,0xac,0x00,0x00 ]
can_id: 0x700
- delay: 200ms
spi:
id: McpSpi
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
canbus:
- platform: mcp2515
id: my_mcp2515
spi_id: McpSpi
cs_pin: GPIO15
can_id: 680
use_extended_id: false
bit_rate: 20kbps
on_frame:
#Warmwasser-Temperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x0e) {
float temperature =float((float((int((x[6])+( (x[5])<<8))))/10));
id(temperature_water).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Vorlauftemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x01 and x[4] == 0xd6) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_forerun).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Rücklauftemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x16) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_return).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Rücklauftemperaturabfrage Sollwert
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[3]==0x00 and x[4] == 0x02) {
float temperature =float(float((int((x[6])+( (x[5])<<8))))/10);
id(temperature_return_setpoint).publish_state(temperature);
ESP_LOGD("main", "Temperature received over can is %f", temperature);
}
#Außentemperaturabfrage
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xe2 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);
}
#EVU Lock
- can_id: 0x480
then:
- lambda: |-
if(x[0]==0xe2 and x[1]==0x00 and x[2]==0xfa and x[3]==0xfd and x[4] == 0xac) {
if(x[5]==0x80 and x[6]==0x00){
id(evu_lock).publish_state(true);
}
else{
id(evu_lock).publish_state(false);
}
}
#Elektrische Leistungsaufnahme Wh /kWh
- can_id: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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));}
}
#Elektrische Leistungsaufnahme kWh / MWH
- can_id: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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: 0x500
then:
- lambda: |-
if(x[0]==0xe2 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));}
}
#Show data in raw form as hex-values
- can_id: 0x180
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
ESP_LOGD("main", "Antwort von 180 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGD("main", "Antwort von 180 Float: %f", wert7);
ESP_LOGD("main", "Antwort von 180 Dez.: %i %i", wert5, wert6);
- can_id: 0x480
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
ESP_LOGD("main", "Antwort von 480 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGD("main", "Antwort von 480 Float: %f", wert7);
ESP_LOGD("main", "Antwort von 480 Dez.: %i %i", wert5, wert6);
- can_id: 0x500
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
ESP_LOGD("main", "Antwort von 500 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGD("main", "Antwort von 500 Float: %f", wert7);
ESP_LOGD("main", "Antwort von 500 Dez.: %i %i", wert5, wert6);
May you share how you connected the board to your heat pump?
I also tried to connect via a DC-DC converter in the beginning. But the display of my pump turned dark when I did this.
I additionally have an FEK connected to the heat pump.
What external devices are connected on your pump?
Hi all,
I had finally some time to hook-up the USBtin and it is working like a charm.
The only issue I now have that I can’t seem to find all the can addresses…
Especially the state of the heat pump. Did one of you find the right one?
I tried 0x0112 and 0x176, which should have the flags set based on the state (according to on other thread I follow (code: https://github.com/Hunv/can2mqtt))
Sorry for the late reply, I have a lot of work at the moment…
There are no external devices connected to the heat pump, except for the necessary sensors.
So there is also no remote control (FEK).
The ESP32, with CAN bus and power supply, is connected to port X15 of the WPM2
On this connector is CAN bus (high & low) and a DC voltage of ~ 22V located:
Dear all,
really great job you did here if only it would work on my installation
My Wemos D1 is integrated into HA, wiring between MCP2515 and LWZ304 and Wemos is checked several times.
I used PSTs code as shown above (Thanks!!!), with some adoption of pin layout as required for Wemos D1 and for sure local settings.
In my log file I can only see:
[hh:mm:ss][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
Any idea?
Thanks for your support!
BR
Jens
@JensPB: If you see nothing at all in your logs, you should probably check your wire-connection.
Below is my updated current code.
As my RAM went out of space at some time after a lot of testing and I ran into boot-loops, I decided to setup new with some changes.
With my new config, you can type a CAN-message as hex-value into home-assistant that is converted via Home-Assistant Script into integer and forwarded via ESP-API to the ESP-device. From there it can
be shown as a package for the CAN-Bus or forwarded to the CAN-Bus by pressing a button.
If you look at the log-files at the same time, you see the answer-packages there, which is good to find new interesting addresses. I added some further sensor-addresses too.
And you can now set the update-interval for each sensor. As I update the value by setting a binary-sensor to true and false using a lambda-call, that is then firing the message.
In Home-Assistant you need to include some input-sensors and a script. The config is below as well.
h_addr is the CAN-Address to send to (usually 3100)
h_idx is the Elster-Index (0000 to ffff)
h_val is the value of the package - if you only want to receive an answer from your device, this is simply 0000.
The ESP-Home configuration is written so, that you don’t have to think about, where to set the ‘fa’ - value. It is set automatically, if needed.
My further idea is, to forward some filtered CAN-packages from the ESP-device directly to home-assistant via API or MQTT. Then RAM is no big problem anymore due to less sensors and buttons in use.
In ESP-Home - part 1:
esphome:
name: esp-sensor-node-hzg
platform: ESP32
board: esp32dev
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "<password>"
services:
- service: pull_canmsg
variables:
idx: int
addr: int
val: int
then:
- lambda: |-
int getA = static_cast<int>(addr); //Adresse in Byte 0 u. 1 schreiben
id(sh_state)[0]=getA>>8;
id(sh_state)[1]=getA-((getA>>8)<<8);
getA = static_cast<int>(idx); //Elster-Index übernehmen
//Wenn Elster-Index <= 0xff => an Byte-Stelle 2 schreiben
if( (getA>>8) == 0x00) {
id(sh_state)[2]=getA-((getA>>8)<<8);
getA = static_cast<int>(val); //Datenwert übernehmen und an Stelle 3 u. 4 schreiben, 5 u. 6 ist 0x00
id(sh_state)[3]=getA>>8;
id(sh_state)[4]=getA-((getA>>8)<<8);
id(sh_state)[5]=0x00;
id(sh_state)[6]=0x00;
}
else {
//Wenn Elster-Index > 0xff kommt 0xfa an Stelle 2, der Index steht dann an Stelle 3 u. 4
id(sh_state)[2]=0xfa;
id(sh_state)[3]=getA>>8;
id(sh_state)[4]=getA-((getA>>8)<<8);
getA = static_cast<int>(val); //der Datenwert steht dann an Stelle 5 u. 6
id(sh_state)[5]=getA>>8;
id(sh_state)[6]=getA-((getA>>8)<<8);
}
ota:
password: "<password>"
wifi:
ssid: "<ssid>"
password: "<password>"
use_address: <addr>
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "<name>"
password: "<password>"
captive_portal:
globals:
#Array zum Senden von Can-Bus Befehl aus Home-Assistant
- id: sh_state
type: int[7]
initial_value: '{0x00,0x00,0x00,0x00,0x00,0x00,0x00}'
restore_value: no
#Array zum Senden von Can-Bus Befehl aus Programmcode
- id: send_state
type: int[7]
initial_value: '{0x00,0x00,0x00,0x00,0x00,0x00,0x00}'
restore_value: no
- 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: volumenstrom_float
type: float
restore_value: no
- id: el_aufnahmeleistung_heiz_total_mWh_flag
type: bool
restore_value: no
- 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: 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
#Abfrage des Sensorstatus durch Ausführen des Lambda-Befehls. send_state wird auf das request-Paket gesetzt. Anschließend wird Update_sensor aktiviert, der den Befehl via CAN absetzt und wieder deaktiviert
sensor:
- platform: template
name: "Außentemperatur"
id: temperature_outside
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x00;id(send_state)[4]=0x0c;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 10min
- platform: template
name: "Quellentemperatur"
id: temperature_source
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x01;id(send_state)[4]=0xd4;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 10min
- platform: template
name: "Warmwassertemperatur"
id: temperature_water
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0x0e;id(send_state)[3]=0x01;id(send_state)[4]=0x00;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 10min
#In Planung
# - platform: template
# name: "WW_Programmstart"
# id: ww_start
# icon: "mdi:timer-play"
# state_class: "measurement"
# accuracy_decimals: 0
#In Planung
# - platform: template
# name: "WW_Programmende"
# id: ww_ende
# icon: "mdi:timer-stop"
# state_class: "measurement"
# accuracy_decimals: 0
#Berechnung COP erfolgt über Sensoren für Stromverbrauch und Wärmeproduktion - kein aktiver Update-Befehl
- platform: template
name: "Verdichterstarts"
id: VD_starts
unit_of_measurement: "a.u."
icon: "mdi:chart-bell-curve-cumulative"
device_class: "power_factor"
state_class: "measurement"
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x07;id(send_state)[4]=0x1c;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x07;id(send_state)[4]=0x1d;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
if (id(VD_starts_t>0) and id(VD_starts_h>0)){
float VD_starts_float = id(VD_starts_h)+id(VD_starts_t);
return VD_starts_float;
}
else {return {};}
update_interval: 5h
accuracy_decimals: 0
- platform: template
name: "COP-Wert Heizung"
id: cop_heater
unit_of_measurement: "a.u."
icon: "mdi:chart-bell-curve-cumulative"
device_class: "power_factor"
state_class: "measurement"
accuracy_decimals: 2
lambda: |-
id(total_electric_energy_heating).update();
id(total_heating_energy).update();
id(total_electric_heating_energy).update();
float heat_cop_float = (id(waermemertrag_heiz_total_mWh)+id(waermemertrag_electr_heiz_total_mWh))/id(el_aufnahmeleistung_heiz_total_mWh);
return heat_cop_float;
force_update: true
- platform: template
name: "COP-Wert Warmwasser"
id: cop_water
unit_of_measurement: "a.u."
icon: "mdi:chart-bell-curve-cumulative"
device_class: "power_factor"
state_class: "measurement"
accuracy_decimals: 2
lambda: |-
id(total_heating_energy_water).update();
id(total_electric_energy_water).update();
id(total_heating_energy_water).update();
float ww_cop_float = (id(waermemertrag_ww_total_mWh)+id(waermemertrag_electr_ww_total_mWh))/id(el_aufnahmeleistung_ww_total_mWh);
return ww_cop_float;
force_update: true
- platform: template
name: "COP-Wert Gesamt"
id: cop_total
unit_of_measurement: "a.u."
icon: "mdi:chart-bell-curve-cumulative"
device_class: "power_factor"
state_class: "measurement"
accuracy_decimals: 2
lambda: |-
id(cop_water).update();
id(cop_heater).update();
float 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));
return total_cop_float;
force_update: true
update_interval: 6h
- platform: template
name: "Rücklauftemperatur Heizung"
id: temperature_return
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-left"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x00;id(send_state)[4]=0x16;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 5min
- platform: template
name: "T Heizkreis IST"
id: t_heizkreis_ist
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-right"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x02;id(send_state)[4]=0xca;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 5min
- platform: template
name: "T Heizkreis Soll"
id: t_heizkreis_soll
unit_of_measurement: "°C"
icon: "mdi:waves-arrow-left"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x01;id(send_state)[4]=0xd7;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 15min
- platform: template
name: "Speicher Soll Temperatur"
id: t_ww_soll
unit_of_measurement: "°C"
icon: "mdi:thermometer-water"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0x03;id(send_state)[3]=0x00;id(send_state)[4]=0x00;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 15min
- platform: template
name: "Speicher IST Temperatur"
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 Speicher Soll Temperatur"
id: ww_temp_eco_log
unit_of_measurement: "°C"
icon: "mdi:thermometer-low"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x0a;id(send_state)[4]=0x06;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 10min
- platform: template
name: "Komfort Speicher Soll Temperatur"
id: ww_temp_komfort_log
unit_of_measurement: "°C"
icon: "mdi:thermometer-high"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0x13;id(send_state)[3]=0x00;id(send_state)[4]=0x00;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 10min
- platform: template
name: "Volumenstrom"
id: volumenstrom_log
unit_of_measurement: "l/min"
icon: "mdi:waves-arrow-right"
state_class: "measurement"
accuracy_decimals: 2
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x06;id(send_state)[4]=0x73;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 1min
- platform: template
name: "Heizungsdruck"
id: heizungsdruck_log
unit_of_measurement: "bar"
icon: "mdi:gauge"
device_class: "pressure"
state_class: "measurement"
accuracy_decimals: 2
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x06;id(send_state)[4]=0x74;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
return {};
update_interval: 7min
- platform: template
name: "Puffertemperatur"
id: puffertemperatur_log
unit_of_measurement: "°C"
icon: "mdi:thermometer-high"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
#Automatische Updates durch FEK
- platform: template
name: "Luftfeuchtigkeit Wohnraum"
id: humidity_inside
unit_of_measurement: "%rH"
icon: "mdi:water-percent"
device_class: "humidity"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Temperatur Wohnraum"
id: temperature_inside
unit_of_measurement: "°C"
icon: "mdi:thermometer-lines"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
- platform: template
name: "Stromverbrauch Warmwasser heute"
id: daily_electric_energy_water
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "measurement"
accuracy_decimals: 3
icon: "mdi:transmission-tower"
lambda: |-
//el. Leistungsaufnahme WW Tag Wh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x1a;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//el. Leistungsaufnahme WW Tag kWh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x1b;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
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);
float daily_electric_energy_water=id(el_aufnahmeleistung_ww_tag_kwh);
id(el_aufnahmeleistung_ww_tag_kwh_flag)=false;
id(el_aufnahmeleistung_ww_tag_wh_flag)=false;
return daily_electric_energy_water;
}
else{return {};}
update_interval: 15min
- platform: template
name: "WM Heizung heute"
id: daily_heating_energy
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "measurement"
accuracy_decimals: 3
lambda: |-
//WM Heizen Tag wh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x2e;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//WM Heizen Tag kwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x2f;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
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);
float daily_heating_energy=id(waermemertrag_heiz_tag_kwh);
id(waermemertrag_heiz_tag_kwh_flag)=false;
id(waermemertrag_heiz_tag_wh_flag)=false;
return daily_heating_energy;
}
else {
return {};
}
update_interval: 15min
- platform: template
name: "Stromverbrauch Heizung heute"
id: daily_electric_energy_heating
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "measurement"
icon: "mdi:transmission-tower"
accuracy_decimals: 3
lambda: |-
//el. Leistungsaufnahme Heizen Tag Wh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x1e;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//el. Leistungsaufnahme Heizen Tag kWh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x1f;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
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);
float daily_electric_energy_heating=id(el_aufnahmeleistung_heiz_tag_kwh);
id(el_aufnahmeleistung_heiz_tag_kwh_flag)=false;
id(el_aufnahmeleistung_heiz_tag_wh_flag)=false;
return daily_electric_energy_heating;
}
else{return {};}
update_interval: 6h
- platform: template
name: "WM Warmwasser heute"
id: daily_heating_energy_water
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "measurement"
accuracy_decimals: 3
lambda: |-
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x2a;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x2b;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
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);
float daily_heating_energy_water=id(waermemertrag_ww_tag_kwh);
id(waermemertrag_ww_tag_kwh_flag)=false;
id(waermemertrag_ww_tag_wh_flag)=false;
return daily_heating_energy_water;
}
else{ return {};
}
update_interval: 15min
- platform: template
name: "Stromverbrauch Warmwasser total"
id: total_electric_energy_water
unit_of_measurement: "MWh"
device_class: "energy"
state_class: "total_increasing"
icon: "mdi:transmission-tower"
accuracy_decimals: 3
lambda: |-
//el. Leistungsaufnahme WW Summe kwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x1c;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//el. Leistungsaufnahme WW Summe Mwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x1d;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
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);
float total_electric_energy_water=id(el_aufnahmeleistung_ww_total_mWh);
id(el_aufnahmeleistung_ww_total_mWh_flag)=false;
id(el_aufnahmeleistung_ww_total_kWh_flag)=false;
return total_electric_energy_water;
}
else { return {};}
- platform: template
name: "Stromverbrauch Heizung total"
id: total_electric_energy_heating
unit_of_measurement: "MWh"
device_class: "energy"
icon: "mdi:transmission-tower"
state_class: "total_increasing"
accuracy_decimals: 3
lambda: |-
//el. Leistungsaufnahme Heizen Summe kwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x20;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//el. Leistungsaufnahme Heizen Summe Mwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x21;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
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);
float total_electric_energy_heating=id(el_aufnahmeleistung_heiz_total_mWh);
id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;
id(el_aufnahmeleistung_heiz_total_mWh_flag)=false;
return total_electric_energy_heating;
}
else {return {};
}
- platform: template
name: "WM Heizen total"
id: total_heating_energy
unit_of_measurement: "MWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
lambda: |-
//WM Heizen Summe kwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x30;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//WM Heizen Summe Mwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x31;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//Überprüfung ob beide Leistungswerte empfangen wurden
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);
float total_heating_energy=id(waermemertrag_heiz_total_mWh);
id(waermemertrag_heiz_total_kWh_flag)=false;
id(waermemertrag_heiz_total_mWh_flag)=false;
return total_heating_energy;
}
else {
return {};
}
In ESP-Home - Part 2:
(Note - just set Part 1 and Part 2 in one file. Its just too long for a post in the forum)
- platform: template
name: "WM Warmwasser total"
id: total_heating_energy_water
unit_of_measurement: "MWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
lambda: |-
//WM WW Summe kwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x2c;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//WM WW Summe Mwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x2d;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//Überprüfung ob beide Leistungswerte empfangen wurden
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);
float total_heating_energy_water=id(waermemertrag_ww_total_mWh);
id(waermemertrag_ww_total_mWh_flag)=false;
id(waermemertrag_ww_total_kWh_flag)=false;
return total_heating_energy_water;
}
else {
return {};
}
- platform: template
name: "WM elektr. Warmwasser total"
id: total_electric_heating_energy_water
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
lambda: |-
//WM NE WW Summe kwh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x24;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//WM NE WW Summe MWh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x25;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//Überprüfung ob beide Leistungswerte empfangen wurden
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);
float total_electric_heating_energy_water=id(waermemertrag_electr_ww_total_mWh);
id(waermemertrag_electr_ww_total_mWh_flag)=false;
id(waermemertrag_electr_ww_total_kWh_flag)=false;
return total_electric_heating_energy_water;
}
else {
return {};
}
- platform: template
name: "WM elektr. heizen total"
id: total_electric_heating_energy
unit_of_measurement: "kWh"
device_class: "energy"
icon: "mdi:water-boiler"
state_class: "total_increasing"
accuracy_decimals: 3
lambda: |-
//WM NE Heizen Summe kWh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x28;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//WM NE Heizen Summe MWh
id(send_state)[0]=0x31;id(send_state)[1]=0x00;id(send_state)[2]=0xfa;id(send_state)[3]=0x09;id(send_state)[4]=0x29;id(send_state)[5]=0x00;id(send_state)[6]=0x00;
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
//Überprüfung ob beide Leistungswerte empfangen wurden
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);
float total_electric_heating_energy=id(waermemertrag_electr_heiz_total_mWh);
id(waermemertrag_electr_heiz_total_kWh_flag)=false;
id(waermemertrag_electr_heiz_total_mWh_flag)=false;
return total_electric_heating_energy;
}
else {
return {};
}
text_sensor:
#Sensor zum verändern der Warmwasser-Komfort-Temperatur für Automatisierung mit PV-Anlage
- platform: homeassistant
name: "ww_komfort_temp"
entity_id: input_text.ww_komfort_temp
id: HASSeingabe_wwkomforttemp
filters:
- lambda: |-
int eingabe=atoi(x.c_str());
if (eingabe < 250 or eingabe > 600) {
//Einfache Abfrage der Temperatur durchführen, falls keine gültige Eingabe erfolgt ist
id(send_state)[0]=0x31;
id(send_state)[1]=0x00;
id(send_state)[2]=0x13;
id(send_state)[3]=0x00;
id(send_state)[4]=0x00;
id(send_state)[5]=0x00;
id(send_state)[6]=0x00;
return x;
} else {
//Wenn User-Eingabe gültig war, Daten für Übertragung an Heizung bereit machen
id(send_state)[0]=0x30;
id(send_state)[1]=0x00;
id(send_state)[2]=0x13;
id(send_state)[3]=eingabe>>8;
id(send_state)[4]=eingabe-((eingabe>>8)<<8);
id(send_state)[5]=0x00;
id(send_state)[6]=0x00;
return x;
}
on_value:
then:
- lambda: |-
//Daten senden
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
#Sensor zum verändern der Warmwasser-Eco-Temperatur für Automatisierung mit PV-Anlage
- platform: homeassistant
name: "ww_eco_temp"
entity_id: input_text.ww_eco_temp
id: HASSeingabe_wwecotemp
filters:
- lambda: |-
int eingabe=atoi(x.c_str());
if (eingabe < 250 or eingabe > 600) {
id(send_state)[0]=0x31;
id(send_state)[1]=0x00;
id(send_state)[2]=0xfa;
id(send_state)[3]=0x0a;
id(send_state)[4]=0x06;
id(send_state)[5]=0x00;
id(send_state)[6]=0x00;
return x;
} else {
id(send_state)[0]=0x30;
id(send_state)[1]=0x00;
id(send_state)[2]=0xfa;
id(send_state)[3]=0x0a;
id(send_state)[4]=0x06;
id(send_state)[5]=eingabe>>8;
id(send_state)[6]=eingabe-((eingabe>>8)<<8);
return x;
}
on_value:
then:
- lambda: |-
id(update_sensor).publish_state(true);
id(update_sensor).publish_state(false);
binary_sensor:
#Heizraum Lichtschalter
- platform: gpio
pin:
number: GPIO16
mode: INPUT_PULLUP
id: licht_heizraum_bn
on_press:
then:
- homeassistant.service:
service: light.turn_on
data:
entity_id: light.eg_heizraum_waschraum
#Sensor zum Senden von CAN-Befehlen aus Lambda-Routinen
- platform: template
id: update_sensor
on_press:
then:
- canbus.send:
data: !lambda
return {(uint8_t) id(send_state)[0],(uint8_t) id(send_state)[1],(uint8_t) id(send_state)[2],(uint8_t) id(send_state)[3], (uint8_t) id(send_state)[4],(uint8_t) id(send_state)[5],(uint8_t) id(send_state)[6]};
can_id: 0x680
button:
#Button für CAN-Befehl im Log anzeigen - CAN-Befehl aus Home-Assistant-Dienst - es wird dabei kein Signal an den CAN-Bus gesendet; Führt auch erstmaliges refresh einzelner Sensoren aus
- platform: template
name: "Befehl anzeigen / Sensorupdate"
id: can_befehl_anzeigen
on_press:
then:
lambda: |-
id(VD_starts).update();
id(cop_total).update();
ESP_LOGI("main", "Value of my hex_sensor: %x, %x, %x, %x, %x, %x, %x", id(sh_state)[0],id(sh_state)[1],id(sh_state)[2],id(sh_state)[3],id(sh_state)[4],id(sh_state)[5],id(sh_state)[6]);
#Button für CAN-Befehl absetzen - CAN-Befehl aus Home-Assistant-Dienst wird an CAN-Bus übermittelt
- platform: template
name: CAN-Befehl absetzen
id: can_send
# Optional variables:
icon: "mdi:emoticon-outline"
on_press:
then:
- canbus.send:
data: !lambda
return {(uint8_t) id(sh_state)[0],(uint8_t) id(sh_state)[1],(uint8_t) id(sh_state)[2],(uint8_t) id(sh_state)[3], (uint8_t) id(sh_state)[4],(uint8_t) id(sh_state)[5],(uint8_t) id(sh_state)[6]};
can_id: 0x680
#Button zum automatisierten reset des ESP-Device
- platform: restart
name: "Heizraum ESP restart"
id: esp_heizraum_restart_bt
on_press:
- logger.log: "Button pressed"
#WW_Programm
# - canbus.send:
# data: [ 0x31, 0x00, 0xfa,0x17,0xa0,0x00,0x00 ]
# can_id: 0x680
# - delay: 500ms
# { "HEISSGAS_TEMP" , 0x0265, et_dec_val}, ok
# - canbus.send:
# data: [ 0x31, 0x00, 0xfa,0x02,0x65,0x00,0x00 ]
# can_id: 0x680
# - delay: 500ms
#Warmwasser Betriebsmodus Abfrage: - ok 1/10
# - canbus.send:
# data: [ 0x31, 0x00, 0xfa,0x01,0x12,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:
#Verdichter Starts 1 000er
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x07 and x[4]==0x1c) {
float VD_x =float((int16_t((x[6])+( (x[5])<<8))))*1000;
id(VD_starts_t)=VD_x;
ESP_LOGD("main", "Verdichter Starts 1000 empfangen over can is %f", VD_x);
}
#Verdichter Starts 100er
- can_id: 0x180
then:
- lambda: |-
if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x07 and x[4]==0x1d) {
int VD_x =((int16_t((x[6])+( (x[5])<<8))));
id(VD_starts_h)=VD_x;
ESP_LOGD("main", "Verdichter Starts 100 empfangen over can is %i", VD_x);
}
#T Heizkreis WW Komfort Soll Wert
- 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);
}
#Volumenstrom (l/min)
- lambda: |-
if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x06 and x[4]==0x73) {
float current =(float((int16_t((x[6])+( (x[5])<<8))))/100);
id(volumenstrom_log).publish_state(current);
id(volumenstrom_float)=current;
ESP_LOGD("main", "l/min Volumenstrom empfangen over can is %f", current);
}
#Heizungsdruck (bar)
- lambda: |-
if(x[0]==0xd2 and x[1]==0x00 and x[2]==0xfa and x[3]==0x06 and x[4]==0x74) {
float pressure =(float((int16_t((x[6])+( (x[5])<<8))))/100);
id(heizungsdruck_log).publish_state(pressure);
ESP_LOGD("main", "bar Heizungsdruck empfangen over can is %f", pressure);
}
#T Puffertemperatur
- lambda: |-
if(x[0]==0x22 and x[1]==0x00 and x[2]==0x0e) {
float temperature =(float((int16_t((x[4])+( (x[3])<<8))))/10);
id(puffertemperatur_log).publish_state(temperature);
ESP_LOGD("main", "T Puffertemperatur 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);
}
#Warmwasser-Temperaturabfrage + Gerätespezifischer 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-Temperatur
- 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-temperatur
- 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ücklauftemperatur
- 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ßentemperatur
#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));}
}
- can_id: 0x180
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
float wert8 = float(int((x[4])+( (x[3])<<8)));
ESP_LOGI("main", "Antwort von 180 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGI("main", "Antwort von 180 Float: %f", wert7);
ESP_LOGI("main", "Antwort von 180 Dez.: %i %i", wert5, wert6);
ESP_LOGI("main", "Antwort klein von 180 Float: %f", wert8);
ESP_LOGI("main", "Antwort klein von 180 Dez.: %i %i", wert3, wert4);
- can_id: 0x700
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
float wert8 = float(int((x[4])+( (x[3])<<8)));
ESP_LOGI("main", "Antwort von 700 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGI("main", "Antwort von 700 Float: %f", wert7);
ESP_LOGI("main", "Antwort von 700 Dez.: %i %i", wert5, wert6);
ESP_LOGI("main", "Antwort klein von 700 Float: %f", wert8);
ESP_LOGI("main", "Antwort klein von 700 Dez.: %i %i", wert3, wert4);
- can_id: 0x480
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
float wert8 = float(int((x[4])+( (x[3])<<8)));
ESP_LOGI("main", "Antwort von 480 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGI("main", "Antwort von 480 Float: %f", wert7);
ESP_LOGI("main", "Antwort von 480 Dez.: %i %i", wert5, wert6);
ESP_LOGI("main", "Antwort klein von 480 Float: %f", wert8);
ESP_LOGI("main", "Antwort klein von 480 Dez.: %i %i", wert3, wert4);
- can_id: 0x100
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
float wert8 = float(int((x[4])+( (x[3])<<8)));
ESP_LOGI("main", "Antwort von 100 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGI("main", "Antwort von 100 Float: %f", wert7);
ESP_LOGI("main", "Antwort von 100 Dez.: %i %i", wert5, wert6);
ESP_LOGI("main", "Antwort klein von 100 Float: %f", wert8);
ESP_LOGI("main", "Antwort klein von 100 Dez.: %i %i", wert3, wert4);
- can_id: 0x301
then:
- lambda: |-
int wert0 = int(x[0]);
int wert1 =int(x[1]);
int wert2 =int(x[2]);
int wert3 =int(x[3]);
int wert4 =int(x[4]);
int wert5 =int(x[5]);
int wert6 =int(x[6]);
float wert7 = float(int((x[6])+( (x[5])<<8)));
float wert8 = float(int((x[4])+( (x[3])<<8)));
ESP_LOGI("main", "Antwort von 301 Hex: %x %x %x %x %x %x %x", wert0, wert1, wert2, wert3, wert4, wert5, wert6);
ESP_LOGI("main", "Antwort von 301 Float: %f", wert7);
ESP_LOGI("main", "Antwort von 301 Dez.: %i %i", wert5, wert6);
ESP_LOGI("main", "Antwort klein von 301 Float: %f", wert8);
ESP_LOGI("main", "Antwort klein von 301 Dez.: %i %i", wert3, wert4);
in Home-Assistant - Config.yaml:
input_text:
# h0-h6: Eingabefelder für Hex-Code an Heizung
h_addr:
name: h_addr
initial: "3100"
min: 4
max: 4
pattern: "[a-fA-F0-9]*"
h_idx:
name: h_idx
initial: "0000"
min: 4
max: 4
pattern: "[a-fA-F0-9]*"
h_val:
name: h_val
initial: "0000"
min: 4
max: 4
pattern: "[a-fA-F0-9]*"
in Home-Assistant - Script.yaml
sequence:
- service: esphome.esp_sensor_node_hzg_pull_canmsg
data:
idx: "{{ states(\"input_text.h_idx\")|int(base=16) }}"
addr: "{{ states(\"input_text.h_addr\")|int(base=16) }}"
val: "{{ states(\"input_text.h_val\")|int(base=16) }}"
mode: queued
icon: mdi:play
max: 5
alias: CAN Nachricht an ESP-Home übertragen
Hi,
Thank you first for your contribution here.
Great work that you do here.
I am new in the Can World, so I need some support.
I receive data from my LWZ304 via my ESP32 with ESPHOME and the MCP2515.
Outside temperature, lead and return. The telegrams are sent from the system every 10 seconds.
But I can´t send a reguest.
e.g. this one
time:
- platform: homeassistant
id: homeassistant_time
on_time:
- seconds: /60
then:
- canbus.send:
data: [ 0x31, 0x00, 0xfa,0x01,0xda,0x00,0x00 ]
can_id: 0x680
- delay: 200ms
There is no answer.
Do I possibly have a problem with the cabling?
I have the ESP32-Wroom-32 model.
It is cabled like this:
Int ----
Sck ---- G18
Si ---- G23
SO ---- G19
CS ---- G15
GND ---- GND
VCC ---- 5V
My config looks like this:
Spi:
ID: McPSpi
CLK_PIN: GPIO18
mosi_pin: gpio23
miso_pin: gpio19
Canbus:
- Platform: MCP2515
ID: My_MCP2515
Spi_id: McPSpi
CS_PIN: GPIO15
can_id: 680
use_exted_id: false
Bit_rate: 20kbps
on_frame:
What do I do wrong?
Many Thanks
Hi,
welcome!
I’m not really sure about the pinnings.
I personally use GPIO17 for the CS-pin - also with an ESP-WROOM-32 device.
Here is another pinout diagram from www.mischianti.org
I just can say, that for sure you should see some traffic in the logs, once you receive any signal from the CAN-bus. There is no need to send requests.
So checking the wires and pinout is not the worst idea.
Sorry, I think I didn’t read correctly.
If you receive a signal but can’t get an answer for a request, you should probably try another receiving CAN-id.
The control unit has not always the CAN-id 180 (addr: 3100) which you use in your code. So maybe you just get no answer, because there is no device with address 180.
I know from another guy, that in his case he sends requests to addr a114.
Have a look at your log-output and post it here. Maybe we can figure out, which device you should address.
Hi robereiter.
Here is the Log:
[20:40:00][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[20:40:02][D][api:102]: Accepted ::FFFF:C0A8:2E1
[20:40:02][D][api.connection:861]: Home Assistant 2022.9.6 (::FFFF:C0A8:2E1): Connected successfully
[20:40:02][D][time:042]: Synchronized time: 2022-09-23 20:40:02
[20:40:25][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:40:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 24 16 0
[20:40:25][D][main:105]: Antwort von 180 Float: 5632.000000
[20:40:25][D][main:106]: Antwort von 180 Dez.: 22 0
[20:40:25][D][canbus:070]: received can message (#2) std can_id=0x180 size=7
[20:40:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 25 14 0
[20:40:25][D][main:105]: Antwort von 180 Float: 5120.000000
[20:40:25][D][main:106]: Antwort von 180 Dez.: 20 0
[20:40:25][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[20:40:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 76 0 1
[20:40:25][D][main:105]: Antwort von 180 Float: 1.000000
[20:40:25][D][main:106]: Antwort von 180 Dez.: 0 1
[20:40:25][D][canbus:070]: received can message (#4) std can_id=0x180 size=7
[20:40:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 23 9 0
[20:40:26][D][main:105]: Antwort von 180 Float: 2304.000000
[20:40:26][D][main:106]: Antwort von 180 Dez.: 9 0
[20:40:26][D][canbus:070]: received can message (#5) std can_id=0x180 size=7
[20:40:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 38 0
[20:40:26][D][main:105]: Antwort von 180 Float: 14336.000000
[20:40:26][D][main:106]: Antwort von 180 Dez.: 56 0
[20:40:45][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:40:45][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 39 0
[20:40:45][D][main:105]: Antwort von 180 Float: 14592.000000
[20:40:45][D][main:106]: Antwort von 180 Dez.: 57 0
[20:41:00][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[20:41:25][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:41:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 24 16 0
[20:41:25][D][main:105]: Antwort von 180 Float: 5632.000000
[20:41:25][D][main:106]: Antwort von 180 Dez.: 22 0
[20:41:25][D][canbus:070]: received can message (#2) std can_id=0x180 size=7
[20:41:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 25 14 0
[20:41:25][D][main:105]: Antwort von 180 Float: 5120.000000
[20:41:25][D][main:106]: Antwort von 180 Dez.: 20 0
[20:41:25][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[20:41:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 76 0 1
[20:41:26][D][main:105]: Antwort von 180 Float: 1.000000
[20:41:26][D][main:106]: Antwort von 180 Dez.: 0 1
[20:41:26][D][canbus:070]: received can message (#4) std can_id=0x180 size=7
[20:41:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 23 9 0
[20:41:26][D][main:105]: Antwort von 180 Float: 2304.000000
[20:41:26][D][main:106]: Antwort von 180 Dez.: 9 0
[20:41:26][D][canbus:070]: received can message (#5) std can_id=0x180 size=7
[20:41:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 39 0
[20:41:26][D][main:105]: Antwort von 180 Float: 14592.000000
[20:41:26][D][main:106]: Antwort von 180 Dez.: 57 0
[20:41:45][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:41:45][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 3a 0
[20:41:45][D][main:105]: Antwort von 180 Float: 14848.000000
[20:41:45][D][main:106]: Antwort von 180 Dez.: 58 0
[20:42:00][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[20:42:25][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:42:25][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 24 16 0
[20:42:25][D][main:105]: Antwort von 180 Float: 5632.000000
[20:42:25][D][main:106]: Antwort von 180 Dez.: 22 0
[20:42:25][D][canbus:070]: received can message (#2) std can_id=0x180 size=7
[20:42:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 0 1 0 0
[20:42:26][D][main:105]: Antwort von 180 Float: 0.000000
[20:42:26][D][main:106]: Antwort von 180 Dez.: 0 0
[20:42:26][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[20:42:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 21 4 0
[20:42:26][D][main:105]: Antwort von 180 Float: 1024.000000
[20:42:26][D][main:106]: Antwort von 180 Dez.: 4 0
[20:42:26][D][canbus:070]: received can message (#4) std can_id=0x180 size=7
[20:42:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 23 9 0
[20:42:26][D][main:105]: Antwort von 180 Float: 2304.000000
[20:42:26][D][main:106]: Antwort von 180 Dez.: 9 0
[20:42:26][D][canbus:070]: received can message (#5) std can_id=0x180 size=7
[20:42:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 25 14 0
[20:42:26][D][main:105]: Antwort von 180 Float: 5120.000000
[20:42:26][D][main:106]: Antwort von 180 Dez.: 20 0
[20:42:45][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:42:45][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 3b 0
[20:42:45][D][main:105]: Antwort von 180 Float: 15104.000000
[20:42:45][D][main:106]: Antwort von 180 Dez.: 59 0
[20:43:00][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[20:43:26][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:43:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 25 14 0
[20:43:26][D][main:105]: Antwort von 180 Float: 5120.000000
[20:43:26][D][main:106]: Antwort von 180 Dez.: 20 0
[20:43:26][D][canbus:070]: received can message (#2) std can_id=0x180 size=7
[20:43:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 76 0 1
[20:43:26][D][main:105]: Antwort von 180 Float: 1.000000
[20:43:26][D][main:106]: Antwort von 180 Dez.: 0 1
[20:43:26][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[20:43:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 22 17 0
[20:43:26][D][main:105]: Antwort von 180 Float: 5888.000000
[20:43:26][D][main:106]: Antwort von 180 Dez.: 23 0
[20:43:26][D][canbus:070]: received can message (#4) std can_id=0x180 size=7
[20:43:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 24 16 0
[20:43:26][D][main:105]: Antwort von 180 Float: 5632.000000
[20:43:26][D][main:106]: Antwort von 180 Dez.: 22 0
[20:43:26][D][canbus:070]: received can message (#5) std can_id=0x180 size=7
[20:43:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 3b 0
[20:43:26][D][main:105]: Antwort von 180 Float: 15104.000000
[20:43:26][D][main:106]: Antwort von 180 Dez.: 59 0
[20:43:45][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:43:45][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 25 15 0
[20:43:45][D][main:105]: Antwort von 180 Float: 5376.000000
[20:43:45][D][main:106]: Antwort von 180 Dez.: 21 0
[20:43:45][D][canbus:070]: received can message (#2) std can_id=0x180 size=7
[20:43:45][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 0 0
[20:43:45][D][main:105]: Antwort von 180 Float: 0.000000
[20:43:45][D][main:106]: Antwort von 180 Dez.: 0 0
[20:44:00][D][canbus:033]: send extended id=0x680 rtr=FALSE size=7
[20:44:26][D][canbus:070]: received can message (#1) std can_id=0x180 size=7
[20:44:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 0 1 0 0
[20:44:26][D][main:105]: Antwort von 180 Float: 0.000000
[20:44:26][D][main:106]: Antwort von 180 Dez.: 0 0
[20:44:26][D][canbus:070]: received can message (#2) std can_id=0x180 size=7
[20:44:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 21 4 0
[20:44:26][D][main:105]: Antwort von 180 Float: 1024.000000
[20:44:26][D][main:106]: Antwort von 180 Dez.: 4 0
[20:44:26][D][canbus:070]: received can message (#3) std can_id=0x180 size=7
[20:44:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 24 16 0
[20:44:26][D][main:105]: Antwort von 180 Float: 5632.000000
[20:44:26][D][main:106]: Antwort von 180 Dez.: 22 0
[20:44:26][D][canbus:070]: received can message (#4) std can_id=0x180 size=7
[20:44:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 26 0 0
[20:44:26][D][main:105]: Antwort von 180 Float: 0.000000
[20:44:26][D][main:106]: Antwort von 180 Dez.: 0 0
[20:44:26][D][canbus:070]: received can message (#5) std can_id=0x180 size=7
[20:44:26][D][main:104]: Antwort von 180 Hex: d0 3c fa 1 76 0 1
[20:44:26][D][main:105]: Antwort von 180 Float: 1.000000
[20:44:26][D][main:106]: Antwort von 180 Dez.: 0 1
Hi,
just identified one of my reasons for not being able to receive correct input (or better none at all)…
So now I at least get some more data, but still not satisfying:
My log looks similar to Miki, but in addition there seems to be no answer on other requests that to ID 180, so it doesn’t work for ID 700:
'21:37:57][D][canbus:069]: received can message (#1) std can_id=0x69e size=7
[21:37:57][D][canbus:069]: received can message (#2) std can_id=0x180 size=7
[21:37:57][D][main:767]: Antwort von 180 Hex: d2 1e fa 0 e 1 b0
[21:37:57][D][main:768]: Antwort von 180 Float: 432.000000
[21:37:57][D][main:769]: Antwort von 180 Dez.: 1 176
[21:37:57][D][canbus:069]: received can message (#1) std can_id=0x69f size=7
[21:37:57][D][canbus:069]: received can message (#2) std can_id=0x302 size=7
[21:37:58][D][canbus:069]: received can message (#1) std can_id=0x69f size=7
[21:37:58][D][canbus:069]: received can message (#1) std can_id=0x180 size=7
[21:37:58][D][main:767]: Antwort von 180 Hex: d2 1f fa 0 e 1 b0
[21:37:58][D][main:768]: Antwort von 180 Float: 432.000000
[21:37:58][D][main:769]: Antwort von 180 Dez.: 1 176
[21:38:00][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:01][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:01][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:01][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:01][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:01][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:02][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:02][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7
[21:38:02][D][canbus:033]: send extended id=0x700 rtr=FALSE size=7'
I hope you are able to interpret this and provide me with an idea
Thanks and have a nice evening!
Jens