swingerman / ha-dual-smart-thermostat

The `dual_smart_thermostat` is an enhaced verion of generic thermostat implemented in Home Assistant. It uses several sensors and dedicated switches connected to a heater and air conditioning under the hood.
https://github.com/swingerman/ha-dual-thermostat
Apache License 2.0
127 stars 21 forks source link

[feat] Better logging #268

Closed jacobw closed 2 months ago

jacobw commented 2 months ago

When things aren't working, there often aren't useful logs to see what's been happening. I'm not an expert on HA logging but perhaps more logging would be consistent with all of the logging from other parts of HA.

Specifically, in the general logging that shows up in the log book (like info level), it would be great to see when this component starts or stops something, with the reason. I.e:

At the moment I see the switch turn off, and the heat pump turn off, so it feels like im missing the component initiating this. You could argue this is what the debug log is for, but its means you can't look back immediately, and its a fair bit of effort to wait foe issues to happen again after debug is enabled. I also don't see this stuff in the debug log either.

Related to this, the debug logging would be more helpful if it identified specific entities, i.eL

2024-08-08 20:08:31.492 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 20:17:27.855 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 20:25:04.074 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 20:42:56.594 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 21:26:18.251 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 21:36:18.550 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 21:42:26.756 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 21:52:19.066 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-08 22:31:24.434 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 00:00:59.996 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 00:15:48.477 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 00:30:37.027 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 00:42:37.397 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 00:58:37.927 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 01:12:46.345 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 01:20:38.627 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 02:14:56.503 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop
2024-08-09 02:57:01.194 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop

It would be much more helpful if it logged the climate entity and the sensor entity (but the climate entity should be enough) otherwise there's no way to know which entity is having issues, or if it is only one entity or multiple.

Lastly, not really a logging issue, but for the logs above, does it call stop if the climate is already idle or off. I believe the logs above are mostly for an entity that is off, in which case it would be great if it checked and turned it off if it was on, the put that in the log book, and debug logs if its already off.

Thanks, Jacob

swingerman commented 2 months ago

Changer many debug level logging to info level. Also, the component provides the hvac_action_reason state attribute that explains why the thermostat is in its current state.

swingerman commented 2 months ago

The improved logging will be included in the next release

jacobw commented 2 months ago

Thanks for doing this @swingerman, Im looking forward to seeing the new logs when this is released.

I had a Quick Look through the commit and I couldn't see if the logging will include information about which entity is causing the issue in the log, i.e:

01.194 WARNING (MainThread) [custom_components.dual_smart_thermostat.climate] Sensor is stalled, call the emergency stop

This doesn't say which sensor is stalled, and which entity the emergency stop has been called on.

I realise hvac_action_reason is set, but often this is empty by the time I want to look at it, which is why it would be good to log it so I can correlate it with an issue.