Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add error code sensor #18

Merged
merged 8 commits into from
Apr 2, 2024
Merged

Conversation

KazWolfe
Copy link
Contributor

Pulled out of the PR #17 for maintainer sanity, and (mostly) resolves Sammy1Am/temp-issues#19.

  • Create a Text Sensor that will report error state to HA as a string.
    • Priority is given to two-digit errors, and then the standard ushort error code.
  • Add a rudimentary timer to check for new errors every ~10 or so cycles.
    • Only runs if a thermostat is not detected.
  • Convert two-digit error codes to the Mitsubishi-readable format.
  • Properly categorizes AG 0x04 as error information.

Copy link
Owner

@Sammy1Am Sammy1Am left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things (see comments), mostly I think we can just lighten some of the logic around sending the requests.

components/mitsubishi_uart/mitsubishi_uart.cpp Outdated Show resolved Hide resolved
@@ -133,6 +134,11 @@ void MitsubishiUART::update() {
hp_bridge.sendPacket(GetRequestPacket::getStatusInstance());
hp_bridge.sendPacket(GetRequestPacket::getCurrentTempInstance());
)

// TODO: get this every 60 seconds instead of every n loops
if (this->_updateLoopCounter % 10 == 0 && !ts_bridge) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't check for !ts_bridge here, just send it anyway. Most of the other packets we send are already redundant with an MHK2 attached. If we want to try to cut down on bandwidth (is this a concern?), we should try to e.g. cache all received packets and only request new ones if we need them. But I think that's a separate change.

Copy link
Contributor Author

@KazWolfe KazWolfe Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My primary concern here revolves around eventually overloading the heat pump with Too Many Things At Once. 2400 baud is plenty for this use case, but it's still rather slow in general.

Assuming we keep requesting more and more information (especially so long as we transparently forward MHK packets), we might start making headaches for ourselves. c.f. specifically akamali/mhk1_mqtt noting the MHK1 has some rather strict timing.

See also #10 for a more broad scope, which might ultimately end with us maintaining our own state and not letting the thermostat talk to the heat pump directly (especially as Kumo does this).

I'm fine going either way here, but I also don't strictly see a need to have errors updated as frequently as active-state. I'm also rather more on the conservative side with how much we shove over the wire, so this may just be a preemptive automation.

Copy link
Contributor Author

@KazWolfe KazWolfe Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: I'll just be lazy for now and send this every time. See inlined comments and above, but I also don't want to deal with thinking of a better implementation for this yet. If we decide to go back to less-frequent polling, can just revert/remove commit b1f66f7 from this PR.

(Please don't resolve this conversation, this is something I'd want to stay easily visible.)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the overloading concern is justified (I've already had some issues e.g. a20950d , and will leave open as requested), but I think the appropriate way to resolve is with a combination of minimum update periods, queue throttling, and caching. Would rather resolve this all at once for all the packets instead of piecemeal.

components/mitsubishi_uart/muart_packet-derived.cpp Outdated Show resolved Hide resolved
While the loop counter overflowing shouldn't cause any particular problems, it's still probably best to just not let it overflow in the first place.

10,000 cycles should be enough for *any* scheduled event until there's a better system for infrequent events.
- Remove identified `auto` typing.
- Simplify error packet else case to not care about logic flaws.
- Check `raw_state` for publish checks, as that's what we're actually setting.
- Remove code to only check errors if the MHK isn't sending those packets.
- Remove the every-n-ticks system.
- Add TODO just in case this does cause issues later.
@Sammy1Am Sammy1Am merged commit 0fa7c68 into Sammy1Am:main Apr 2, 2024
@KazWolfe KazWolfe deleted the feat/error-codes branch April 2, 2024 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants