Skip to content

Conversation

@rneswold
Copy link
Contributor

@rneswold rneswold commented Jan 7, 2026

This PR has several important changes:

  • The TP-Link driver now uses the SharedReadWriteDevice type for managing state. This means I can control my TP-Link devices manually, and DrMem will leave it in "manual mode" for a predetermined amount of time (4 hours, at the moment.)
  • The TP-Link now support switch devices in addition to dimmer devices. I've tested it with Kasa WiFi outlets.
  • Fixed a race condition when starting the drivers and logic blocks
  • Cleaned up log messages

The `Dimmer` class was changed to use `SharedReadWriteDevice` types.
This commit also required changes to the TP-Link driver (which only
supports the HS220 dimmer.) The driver isn't using the `Shared` type
as it was intended, so the TP-Link might not work. This will be
verified or fixed.
This module holds types that are assigned to fields in requests.
A lot of the types were too exposed. This moves definitions into areas
that restrict their access. Also got rid of `CmdWriter`; it was a
complication that a lot of areas needed. Instead, I created a `crypt`
module and put simple `encode` and `decode` functions in it.  The
`CmdWriter` was no longer necessary since `Vec<>` is a `Writer` for
the `serde_json` API. 🎉
- Add an error device to report errors
- Make the read/write device sharable
Its contents were incorporated into another file, but I forgot to
delete the source file.
This driver now correctly uses the `SharedReadWriteDevice` API. It
also adds support for switches (i.e. non-dimmer devices.)
These messages should use a more consistent convention.
With a small set of configured drivers and a few logic blocks, there
was a chance that the logic blocks would try to initialize before all
the drivers registered their devices. This commit adds barriers to the
driver start-up code so that we don't proceed to the logic block
start-up until all devices are registered with core.

This also simplifies the logic block start-up by having a simple
barrier instead of nested barriers.
@rneswold
Copy link
Contributor Author

rneswold commented Jan 7, 2026

I still need to make another change to the driver. Right now, as it's trying to connect to the device, it's not listening or handling incoming settings. It needs to process settings in a timely fashion no matter what and right now, settings will hang until a connection is made. This may seem like a short time and ignorable but I use one of the outlets to control the Christmas tree lights. Most of the year the WiFi outlet is in a drawer so settings to that device would hang until the outlet is plugged back in.

@rneswold
Copy link
Contributor Author

rneswold commented Jan 8, 2026

I also need to update the SharedReadWriteDevice API to let the override timeout be specified by the driver and/or the config file. The timeout should be an Option<Duration> so that None means the only way to leave override mode is to set it back to the current setting. This works well for boolean devices.

- `drmem-api` is now v0.6.1
- `drmem-drv-tplink` is now v0.6.1 and depends on `drmem-api` v0.6.1
This commit adds a parameter when registering devices that specifies
the override timeout. Only SharedReadWriteDevice devices actually use
this parameter. It'll be ignored for devices that can't be modified in
the real world.
This driver now should be responsive to settings even when connecting
and when sleeping between reconnects.
@rneswold rneswold merged commit f139c2c into DrMemCS:main Jan 16, 2026
3 checks passed
@rneswold rneswold deleted the dimmer-to-shared branch January 16, 2026 04:06
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.

1 participant