mirror of https://github.com/arendst/Tasmota.git
parent
2607edb54c
commit
d033c2b5ee
|
@ -1269,6 +1269,28 @@ void ThermostatVirtualSwitchCtrState(uint8_t ctr_output)
|
||||||
MqttPublish(domoticz_in_topic);
|
MqttPublish(domoticz_in_topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t ThermostatGetDutyCycle(uint8_t ctr_output)
|
||||||
|
{
|
||||||
|
uint8_t value = 0;
|
||||||
|
if ( (Thermostat[ctr_output].status.controller_mode == CTR_PI)
|
||||||
|
|| ((Thermostat[ctr_output].status.controller_mode == CTR_HYBRID)
|
||||||
|
&&(Thermostat[ctr_output].status.phase_hybrid_ctr == CTR_HYBRID_PI))) {
|
||||||
|
value = Thermostat[ctr_output].time_total_pi / Thermostat[ctr_output].time_pi_cycle;
|
||||||
|
}
|
||||||
|
else if ( (Thermostat[ctr_output].status.controller_mode == CTR_RAMP_UP)
|
||||||
|
|| ((Thermostat[ctr_output].status.controller_mode == CTR_HYBRID)
|
||||||
|
&&(Thermostat[ctr_output].status.phase_hybrid_ctr == CTR_HYBRID_RAMP_UP))) {
|
||||||
|
if (Thermostat[ctr_output].status.status_output == IFACE_ON) {
|
||||||
|
value = 100;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ThermostatDebug(uint8_t ctr_output)
|
void ThermostatDebug(uint8_t ctr_output)
|
||||||
{
|
{
|
||||||
char result_chr[FLOATSZ];
|
char result_chr[FLOATSZ];
|
||||||
|
@ -1950,23 +1972,8 @@ void CmndCtrDutyCycleRead(void)
|
||||||
{
|
{
|
||||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= THERMOSTAT_CONTROLLER_OUTPUTS)) {
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= THERMOSTAT_CONTROLLER_OUTPUTS)) {
|
||||||
uint8_t ctr_output = XdrvMailbox.index - 1;
|
uint8_t ctr_output = XdrvMailbox.index - 1;
|
||||||
uint8_t value = 0;
|
|
||||||
if ( (Thermostat[ctr_output].status.controller_mode == CTR_PI)
|
ResponseCmndIdxNumber((int)ThermostatGetDutyCycle(ctr_output) );
|
||||||
|| ((Thermostat[ctr_output].status.controller_mode == CTR_HYBRID)
|
|
||||||
&&(Thermostat[ctr_output].status.phase_hybrid_ctr == CTR_HYBRID_PI))) {
|
|
||||||
value = Thermostat[ctr_output].time_total_pi / Thermostat[ctr_output].time_pi_cycle;
|
|
||||||
}
|
|
||||||
else if ( (Thermostat[ctr_output].status.controller_mode == CTR_RAMP_UP)
|
|
||||||
|| ((Thermostat[ctr_output].status.controller_mode == CTR_HYBRID)
|
|
||||||
&&(Thermostat[ctr_output].status.phase_hybrid_ctr == CTR_HYBRID_RAMP_UP))) {
|
|
||||||
if (Thermostat[ctr_output].status.status_output == IFACE_ON) {
|
|
||||||
value = 100;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
value = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResponseCmndIdxNumber((int)value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1984,6 +1991,60 @@ void CmndEnableOutputSet(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************************\
|
||||||
|
* Web UI
|
||||||
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
// xdrv_39_thermostat.ino
|
||||||
|
#define D_THERMOSTAT "Thermostat"
|
||||||
|
#define D_THERMOSTAT_SET_POINT "Set Point"
|
||||||
|
#define D_THERMOSTAT_SENSOR "Sensor"
|
||||||
|
#define D_THERMOSTAT_GRADIENT "Gradient"
|
||||||
|
#define D_THERMOSTAT_DUTY_CYCLE "Duty Cycle"
|
||||||
|
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
const char HTTP_THERMOSTAT_INFO[] PROGMEM = "{s}" D_THERMOSTAT "{m}%s{e}";
|
||||||
|
const char HTTP_THERMOSTAT_TEMPERATURE[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%*_f " D_UNIT_DEGREE "%c{e}";
|
||||||
|
const char HTTP_THERMOSTAT_DUTY_CYCLE[] PROGMEM = "{s}" D_THERMOSTAT_DUTY_CYCLE "{m}%d " D_UNIT_PERCENT "{e}";
|
||||||
|
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
|
|
||||||
|
void ThermostatShow(uint8_t ctr_output)
|
||||||
|
{
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
|
||||||
|
if (Thermostat[ctr_output].status.thermostat_mode == THERMOSTAT_OFF) {
|
||||||
|
WSContentSend_P(HTTP_THERMOSTAT_INFO, D_DISABLED );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
char c_unit = Thermostat[ctr_output].status.temp_format==TEMP_CELSIUS ? D_UNIT_CELSIUS[0] : D_UNIT_FAHRENHEIT[0];
|
||||||
|
float f_temperature ;
|
||||||
|
|
||||||
|
WSContentSend_P(HTTP_THERMOSTAT_INFO, D_ENABLED );
|
||||||
|
|
||||||
|
f_temperature = Thermostat[ctr_output].temp_target_level / 10.0f ;
|
||||||
|
WSContentSend_PD(HTTP_THERMOSTAT_TEMPERATURE, D_THERMOSTAT_SET_POINT, Settings->flag2.temperature_resolution, &f_temperature, c_unit);
|
||||||
|
|
||||||
|
f_temperature = Thermostat[ctr_output].temp_measured / 10.0f;
|
||||||
|
WSContentSend_PD(HTTP_THERMOSTAT_TEMPERATURE, D_THERMOSTAT_SENSOR, Settings->flag2.temperature_resolution, &f_temperature, c_unit);
|
||||||
|
|
||||||
|
int16_t value = Thermostat[ctr_output].temp_measured_gradient;
|
||||||
|
if (Thermostat[ctr_output].status.temp_format == TEMP_FAHRENHEIT) {
|
||||||
|
value = ThermostatCelsiusToFahrenheit((int32_t)Thermostat[ctr_output].temp_measured_gradient, TEMP_CONV_RELATIVE);
|
||||||
|
}
|
||||||
|
f_temperature = value / 1000.0f;
|
||||||
|
WSContentSend_PD(HTTP_THERMOSTAT_TEMPERATURE, D_THERMOSTAT_GRADIENT, Settings->flag2.temperature_resolution, &f_temperature, c_unit);
|
||||||
|
WSContentSend_P(HTTP_THERMOSTAT_DUTY_CYCLE, ThermostatGetDutyCycle(ctr_output) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Interface
|
* Interface
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -2029,6 +2090,15 @@ bool Xdrv39(uint8_t function)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
case FUNC_WEB_SENSOR:
|
||||||
|
for (ctr_output = 0; ctr_output < THERMOSTAT_CONTROLLER_OUTPUTS; ctr_output++) {
|
||||||
|
ThermostatShow(ctr_output);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif // USE_WEBSERVER
|
||||||
|
|
||||||
case FUNC_COMMAND:
|
case FUNC_COMMAND:
|
||||||
result = DecodeCommand(kThermostatCommands, ThermostatCommand);
|
result = DecodeCommand(kThermostatCommands, ThermostatCommand);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue