diff --git a/dietrich.h b/dietrich.h index 7d54e61..f2f2ba0 100644 --- a/dietrich.h +++ b/dietrich.h @@ -131,60 +131,60 @@ class Dietrich : public PollingComponent, public UARTDevice { int bits = 0; - if (flow_temp_sensor->get_name().length()>0) flow_temp_sensor->publish_state(signedFloat((readdata[8]*256)+readdata[7])*0.01); delay(100); //delay for esphome to not disconnect api - if (return_temp_sensor->get_name().length()>0) return_temp_sensor->publish_state(signedFloat((readdata[10]*256)+readdata[9])*0.01); delay(100); //delay for esphome to not disconnect api - if (dhw_in_temp_sensor->get_name().length()>0) dhw_in_temp_sensor->publish_state(signedFloat((readdata[12]*256)+readdata[11])*0.01); delay(100); //delay for esphome to not disconnect api - if (outside_temp_sensor->get_name().length()>0) outside_temp_sensor->publish_state(signedFloat((readdata[14]*256)+readdata[13])*0.01); delay(100); //delay for esphome to not disconnect api - if (calorifier_temp_sensor->get_name().length()>0) calorifier_temp_sensor->publish_state(signedFloat((readdata[16]*256)+readdata[15])*0.01); delay(100); //delay for esphome to not disconnect api - if (boiler_control_temp_sensor->get_name().length()>0) boiler_control_temp_sensor->publish_state(signedFloat((readdata[20]*256)+readdata[19])*0.01); delay(100); //delay for esphome to not disconnect api - if (room_temp_sensor->get_name().length()>0) room_temp_sensor->publish_state(signedFloat((readdata[22]*256)+readdata[21])*0.01); delay(100); //delay for esphome to not disconnect api - if (ch_setpoint_sensor->get_name().length()>0) ch_setpoint_sensor->publish_state(signedFloat((readdata[24]*256)+readdata[23])*0.01); delay(100); //delay for esphome to not disconnect api - if (dhw_setpoint_sensor->get_name().length()>0) dhw_setpoint_sensor->publish_state(signedFloat((readdata[26]*256)+readdata[25])*0.01); delay(100); //delay for esphome to not disconnect api - if (room_temp_setpoint_sensor->get_name().length()>0) room_temp_setpoint_sensor->publish_state(signedFloat((readdata[28]*256)+readdata[27])*0.01); delay(100); //delay for esphome to not disconnect api + if (flow_temp_sensor->get_name().empty()==0) flow_temp_sensor->publish_state(signedFloat((readdata[8]*256)+readdata[7])*0.01); delay(100); //delay for esphome to not disconnect api + if(return_temp_sensor->get_name().empty()==0) return_temp_sensor->publish_state(signedFloat((readdata[10]*256)+readdata[9])*0.01); delay(100); //delay for esphome to not disconnect api + if(dhw_in_temp_sensor->get_name().empty()==0) dhw_in_temp_sensor->publish_state(signedFloat((readdata[12]*256)+readdata[11])*0.01); delay(100); //delay for esphome to not disconnect api + if(outside_temp_sensor->get_name().empty()==0) outside_temp_sensor->publish_state(signedFloat((readdata[14]*256)+readdata[13])*0.01); delay(100); //delay for esphome to not disconnect api + if(calorifier_temp_sensor->get_name().empty()==0) calorifier_temp_sensor->publish_state(signedFloat((readdata[16]*256)+readdata[15])*0.01); delay(100); //delay for esphome to not disconnect api + if(boiler_control_temp_sensor->get_name().empty()==0) boiler_control_temp_sensor->publish_state(signedFloat((readdata[20]*256)+readdata[19])*0.01); delay(100); //delay for esphome to not disconnect api + if(room_temp_sensor->get_name().empty()==0) room_temp_sensor->publish_state(signedFloat((readdata[22]*256)+readdata[21])*0.01); delay(100); //delay for esphome to not disconnect api + if(ch_setpoint_sensor->get_name().empty()==0) ch_setpoint_sensor->publish_state(signedFloat((readdata[24]*256)+readdata[23])*0.01); delay(100); //delay for esphome to not disconnect api + if(dhw_setpoint_sensor->get_name().empty()==0) dhw_setpoint_sensor->publish_state(signedFloat((readdata[26]*256)+readdata[25])*0.01); delay(100); //delay for esphome to not disconnect api + if(room_temp_setpoint_sensor->get_name().empty()==0) room_temp_setpoint_sensor->publish_state(signedFloat((readdata[28]*256)+readdata[27])*0.01); delay(100); //delay for esphome to not disconnect api if (sem_read_all) { - if (fan_speed_setpoint_sensor->get_name().length()>0) fan_speed_setpoint_sensor->publish_state(signedFloat((readdata[30]*256)+readdata[29])); delay(100); //delay for esphome to not disconnect api - if (fan_speed_sensor->get_name().length()>0) fan_speed_sensor->publish_state(signedFloat((readdata[32]*256)+readdata[31])); delay(100); //delay for esphome to not disconnect api - if (ionisation_current_sensor->get_name().length()>0) ionisation_current_sensor->publish_state(readdata[33]); delay(100); //delay for esphome to not disconnect api - if (internal_setpoint_sensor->get_name().length()>0) internal_setpoint_sensor->publish_state(signedFloat((readdata[35]*256)+readdata[34])*0.01); delay(100); //delay for esphome to not disconnect api - if (available_power_sensor->get_name().length()>0) available_power_sensor->publish_state(readdata[36]); delay(100); //delay for esphome to not disconnect api - if (pump_percentage_sensor->get_name().length()>0) pump_percentage_sensor->publish_state(readdata[37]); delay(100); //delay for esphome to not disconnect api - if (desired_max_power_sensor->get_name().length()>0) desired_max_power_sensor->publish_state(readdata[39]); delay(100); //delay for esphome to not disconnect api - if (actual_power_sensor->get_name().length()>0) actual_power_sensor->publish_state(readdata[40]); delay(100); //delay for esphome to not disconnect api + if(fan_speed_setpoint_sensor->get_name().empty()==0) fan_speed_setpoint_sensor->publish_state(signedFloat((readdata[30]*256)+readdata[29])); delay(100); //delay for esphome to not disconnect api + if(fan_speed_sensor->get_name().empty()==0) fan_speed_sensor->publish_state(signedFloat((readdata[32]*256)+readdata[31])); delay(100); //delay for esphome to not disconnect api + if(ionisation_current_sensor->get_name().empty()==0) ionisation_current_sensor->publish_state(readdata[33]); delay(100); //delay for esphome to not disconnect api + if(internal_setpoint_sensor->get_name().empty()==0) internal_setpoint_sensor->publish_state(signedFloat((readdata[35]*256)+readdata[34])*0.01); delay(100); //delay for esphome to not disconnect api + if(available_power_sensor->get_name().empty()==0) available_power_sensor->publish_state(readdata[36]); delay(100); //delay for esphome to not disconnect api + if(pump_percentage_sensor->get_name().empty()==0) pump_percentage_sensor->publish_state(readdata[37]); delay(100); //delay for esphome to not disconnect api + if(desired_max_power_sensor->get_name().empty()==0) desired_max_power_sensor->publish_state(readdata[39]); delay(100); //delay for esphome to not disconnect api + if(actual_power_sensor->get_name().empty()==0) actual_power_sensor->publish_state(readdata[40]); delay(100); //delay for esphome to not disconnect api bits = readdata[43]; - if (demand_source_bit0_sensor->get_name().length()>0) demand_source_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit1_sensor->get_name().length()>0) demand_source_bit1_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit2_sensor->get_name().length()>0) demand_source_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit3_sensor->get_name().length()>0) demand_source_bit3_sensor->publish_state(bitRead(bits, 3)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit4_sensor->get_name().length()>0) demand_source_bit4_sensor->publish_state(bitRead(bits, 4)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit5_sensor->get_name().length()>0) demand_source_bit5_sensor->publish_state(bitRead(bits, 5)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit6_sensor->get_name().length()>0) demand_source_bit6_sensor->publish_state(bitRead(bits, 6)); delay(100); //delay for esphome to not disconnect api - if (demand_source_bit7_sensor->get_name().length()>0) demand_source_bit7_sensor->publish_state(bitRead(bits, 7)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit0_sensor->get_name().empty()==0) demand_source_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit1_sensor->get_name().empty()==0) demand_source_bit1_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit2_sensor->get_name().empty()==0) demand_source_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit3_sensor->get_name().empty()==0) demand_source_bit3_sensor->publish_state(bitRead(bits, 3)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit4_sensor->get_name().empty()==0) demand_source_bit4_sensor->publish_state(bitRead(bits, 4)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit5_sensor->get_name().empty()==0) demand_source_bit5_sensor->publish_state(bitRead(bits, 5)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit6_sensor->get_name().empty()==0) demand_source_bit6_sensor->publish_state(bitRead(bits, 6)); delay(100); //delay for esphome to not disconnect api + if(demand_source_bit7_sensor->get_name().empty()==0) demand_source_bit7_sensor->publish_state(bitRead(bits, 7)); delay(100); //delay for esphome to not disconnect api bits = readdata[44]; - if (input_bit0_sensor->get_name().length()>0) input_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api - if (input_bit1_sensor->get_name().length()>0) input_bit1_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api - if (input_bit2_sensor->get_name().length()>0) input_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api - if (input_bit3_sensor->get_name().length()>0) input_bit3_sensor->publish_state(bitRead(bits, 3)); delay(100); //delay for esphome to not disconnect api - if (input_bit5_sensor->get_name().length()>0) input_bit5_sensor->publish_state(bitRead(bits, 5)); delay(100); //delay for esphome to not disconnect api - if (input_bit6_sensor->get_name().length()>0) input_bit6_sensor->publish_state(bitRead(bits, 6)); delay(100); //delay for esphome to not disconnect api - if (input_bit7_sensor->get_name().length()>0) input_bit7_sensor->publish_state(bitRead(bits, 7)); delay(100); //delay for esphome to not disconnect api + if(input_bit0_sensor->get_name().empty()==0) input_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api + if(input_bit1_sensor->get_name().empty()==0) input_bit1_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api + if(input_bit2_sensor->get_name().empty()==0) input_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api + if(input_bit3_sensor->get_name().empty()==0) input_bit3_sensor->publish_state(bitRead(bits, 3)); delay(100); //delay for esphome to not disconnect api + if(input_bit5_sensor->get_name().empty()==0) input_bit5_sensor->publish_state(bitRead(bits, 5)); delay(100); //delay for esphome to not disconnect api + if(input_bit6_sensor->get_name().empty()==0) input_bit6_sensor->publish_state(bitRead(bits, 6)); delay(100); //delay for esphome to not disconnect api + if(input_bit7_sensor->get_name().empty()==0) input_bit7_sensor->publish_state(bitRead(bits, 7)); delay(100); //delay for esphome to not disconnect api bits = readdata[45]; - if (valve_bit0_sensor->get_name().length()>0) valve_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api - if (valve_bit2_sensor->get_name().length()>0) valve_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api - if (valve_bit3_sensor->get_name().length()>0) valve_bit3_sensor->publish_state(bitRead(bits, 3)); delay(100); //delay for esphome to not disconnect api - if (valve_bit4_sensor->get_name().length()>0) valve_bit4_sensor->publish_state(bitRead(bits, 4)); delay(100); //delay for esphome to not disconnect api - if (valve_bit6_sensor->get_name().length()>0) valve_bit6_sensor->publish_state(bitRead(bits, 6)); delay(100); //delay for esphome to not disconnect api + if(valve_bit0_sensor->get_name().empty()==0) valve_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api + if(valve_bit2_sensor->get_name().empty()==0) valve_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api + if(valve_bit3_sensor->get_name().empty()==0) valve_bit3_sensor->publish_state(bitRead(bits, 3)); delay(100); //delay for esphome to not disconnect api + if(valve_bit4_sensor->get_name().empty()==0) valve_bit4_sensor->publish_state(bitRead(bits, 4)); delay(100); //delay for esphome to not disconnect api + if(valve_bit6_sensor->get_name().empty()==0) valve_bit6_sensor->publish_state(bitRead(bits, 6)); delay(100); //delay for esphome to not disconnect api bits = readdata[46]; - if (pump_bit0_sensor->get_name().length()>0) pump_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api - if (pump_bit1_sensor->get_name().length()>0) pump_bit1_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api - if (pump_bit2_sensor->get_name().length()>0) pump_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api - if (pump_bit4_sensor->get_name().length()>0) pump_bit4_sensor->publish_state(bitRead(bits, 4)); delay(100); //delay for esphome to not disconnect api - if (pump_bit7_sensor->get_name().length()>0) pump_bit7_sensor->publish_state(bitRead(bits, 7)); delay(100); //delay for esphome to not disconnect api + if(pump_bit0_sensor->get_name().empty()==0) pump_bit0_sensor->publish_state(bitRead(bits, 0)); delay(100); //delay for esphome to not disconnect api + if(pump_bit1_sensor->get_name().empty()==0) pump_bit1_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api + if(pump_bit2_sensor->get_name().empty()==0) pump_bit2_sensor->publish_state(bitRead(bits, 2)); delay(100); //delay for esphome to not disconnect api + if(pump_bit4_sensor->get_name().empty()==0) pump_bit4_sensor->publish_state(bitRead(bits, 4)); delay(100); //delay for esphome to not disconnect api + if(pump_bit7_sensor->get_name().empty()==0) pump_bit7_sensor->publish_state(bitRead(bits, 7)); delay(100); //delay for esphome to not disconnect api } state_sensor->publish_state(readdata[47]); delay(200); //delay for esphome to not disconnect api @@ -193,13 +193,13 @@ class Dietrich : public PollingComponent, public UARTDevice { sub_state_sensor->publish_state(readdata[50]); delay(200); //delay for esphome to not disconnect api if (sem_read_all) { - if (hydro_pressure_sensor->get_name().length()>0) hydro_pressure_sensor->publish_state(readdata[56]); delay(100); //delay for esphome to not disconnect api + if(hydro_pressure_sensor->get_name().empty()==0) hydro_pressure_sensor->publish_state(readdata[56]); delay(100); //delay for esphome to not disconnect api bits = readdata[57]; - if (hru_sensor->get_name().length()>0) hru_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api + if(hru_sensor->get_name().empty()==0) hru_sensor->publish_state(bitRead(bits, 1)); delay(100); //delay for esphome to not disconnect api - if (control_temp_sensor->get_name().length()>0) control_temp_sensor->publish_state(signedFloat((readdata[59]*256)+readdata[58])*0.01); delay(100); //delay for esphome to not disconnect api - if (dhw_flowrate_sensor->get_name().length()>0) dhw_flowrate_sensor->publish_state(signedFloat((readdata[61]*256)+readdata[60])*0.01); delay(100); //delay for esphome to not disconnect api + if(control_temp_sensor->get_name().empty()==0) control_temp_sensor->publish_state(signedFloat((readdata[59]*256)+readdata[58])*0.01); delay(100); //delay for esphome to not disconnect api + if(dhw_flowrate_sensor->get_name().empty()==0) dhw_flowrate_sensor->publish_state(signedFloat((readdata[61]*256)+readdata[60])*0.01); delay(100); //delay for esphome to not disconnect api } sem_read_all=!sem_read_all; @@ -229,14 +229,14 @@ class Dietrich : public PollingComponent, public UARTDevice { if (readdata[0]==2 && readdata[1]==0 && readdata[2]==254) {//add crc check - if (hours_run_pump_sensor->get_name().length()>0) hours_run_pump_sensor->publish_state(((readdata[7]*256)+readdata[8])*2); delay(100); //delay for esphome to not disconnect api - if (hours_run_3way_sensor->get_name().length()>0) hours_run_3way_sensor->publish_state(((readdata[9]*256)+readdata[10])*2); delay(100); //delay for esphome to not disconnect api - if (hours_run_ch_sensor->get_name().length()>0) hours_run_ch_sensor->publish_state(((readdata[11]*256)+readdata[12])*2); delay(100); //delay for esphome to not disconnect api - if (hours_run_dhw_sensor->get_name().length()>0) hours_run_dhw_sensor->publish_state(((readdata[13]*256)+readdata[14])); delay(100); //delay for esphome to not disconnect api - if (power_supply_aval_hours_sensor->get_name().length()>0) power_supply_aval_hours_sensor->publish_state(((readdata[15]*256)+readdata[16])*2); delay(100); //delay for esphome to not disconnect api - if (pump_starts_sensor->get_name().length()>0) pump_starts_sensor->publish_state(((readdata[17]*256)+readdata[18])*8); delay(100); //delay for esphome to not disconnect api - if (number_of3way_valce_cycles_sensor->get_name().length()>0) number_of3way_valce_cycles_sensor->publish_state(((readdata[19]*256)+readdata[20])*8); delay(100); //delay for esphome to not disconnect api - if (burner_start_dhw_sensor->get_name().length()>0) burner_start_dhw_sensor->publish_state(((readdata[21]*256)+readdata[22])*8); delay(100); //delay for esphome to not disconnect api + if(hours_run_pump_sensor->get_name().empty()==0) hours_run_pump_sensor->publish_state(((readdata[7]*256)+readdata[8])*2); delay(100); //delay for esphome to not disconnect api + if(hours_run_3way_sensor->get_name().empty()==0) hours_run_3way_sensor->publish_state(((readdata[9]*256)+readdata[10])*2); delay(100); //delay for esphome to not disconnect api + if(hours_run_ch_sensor->get_name().empty()==0) hours_run_ch_sensor->publish_state(((readdata[11]*256)+readdata[12])*2); delay(100); //delay for esphome to not disconnect api + if(hours_run_dhw_sensor->get_name().empty()==0) hours_run_dhw_sensor->publish_state(((readdata[13]*256)+readdata[14])); delay(100); //delay for esphome to not disconnect api + if(power_supply_aval_hours_sensor->get_name().empty()==0) power_supply_aval_hours_sensor->publish_state(((readdata[15]*256)+readdata[16])*2); delay(100); //delay for esphome to not disconnect api + if(pump_starts_sensor->get_name().empty()==0) pump_starts_sensor->publish_state(((readdata[17]*256)+readdata[18])*8); delay(100); //delay for esphome to not disconnect api + if(number_of3way_valce_cycles_sensor->get_name().empty()==0) number_of3way_valce_cycles_sensor->publish_state(((readdata[19]*256)+readdata[20])*8); delay(100); //delay for esphome to not disconnect api + if(burner_start_dhw_sensor->get_name().empty()==0) burner_start_dhw_sensor->publish_state(((readdata[21]*256)+readdata[22])*8); delay(100); //delay for esphome to not disconnect api } array_to_string(readdata, 28, str); @@ -252,9 +252,9 @@ class Dietrich : public PollingComponent, public UARTDevice { } if (readdata[0]==2 && readdata[1]==0 && readdata[2]==254) {//add crc check - if (total_burner_start_sensor->get_name().length()>0) total_burner_start_sensor->publish_state(((readdata[7]*256)+readdata[8])*8); delay(100); //delay for esphome to not disconnect api - if (failed_burner_start_sensor->get_name().length()>0) failed_burner_start_sensor->publish_state(((readdata[9]*256)+readdata[10])); delay(100); //delay for esphome to not disconnect api - if (number_flame_loss_sensor->get_name().length()>0) number_flame_loss_sensor->publish_state(((readdata[11]*256)+readdata[12])); delay(100); //delay for esphome to not disconnect api + if(total_burner_start_sensor->get_name().empty()==0) total_burner_start_sensor->publish_state(((readdata[7]*256)+readdata[8])*8); delay(100); //delay for esphome to not disconnect api + if(failed_burner_start_sensor->get_name().empty()==0) failed_burner_start_sensor->publish_state(((readdata[9]*256)+readdata[10])); delay(100); //delay for esphome to not disconnect api + if(number_flame_loss_sensor->get_name().empty()==0) number_flame_loss_sensor->publish_state(((readdata[11]*256)+readdata[12])); delay(100); //delay for esphome to not disconnect api } array_to_string(readdata, 28, str); @@ -283,4 +283,4 @@ class Dietrich : public PollingComponent, public UARTDevice { sem_reading_data=false; } -}; \ No newline at end of file +};