Migrating complex automation from WebCoRE

I’ve been only occasionally monitoring the migration away from Groovy and wondering what to do with my most complicated piston running in WebCoRE. Earlier this week, one of the involved devices migrated to an Edge driver and I expected the automation to stop running, but much to my surprise it seems to be continuing to work – at least for the moment. I know the end is nigh though and am looking for some guidance about where to migrate the automation.

The automation in question controls a bathroom ventilation fan that is controlled by a Z-Wave switch. There’s also a humidity sensor in the bathroom, and the automation further relies on the humidity level reported by a thermostat elsewhere in the house to establish baseline humidity.

There are two overlapping bits of functionality. First, the automation calculates the delta between the humidity inside the bathroom and the humidity outside the bathroom. When that rises above a threshold, it turns on the fan. When the delta drops below a (lower) threshold, it turns off the fan.

Second, there’s manual control: if someone turns on the fan, it turns itself off after 15 minutes (unless there’s excess humidity in the bathroom); if someone turns off the fan, it stays off (even if there’s excess humidity, until the humidity clears and it becomes humid again).

Working out the logic given the overlapping conditions was kind of fun, and the automation works nicely. But given the imminent disappearance of Groovy in the ST world, what’s the best way to replicate this functionality? The potentially tricky bits are being able to calculate a delta between humidity values coming from two devices, looking for threshold crossings of that delta, and keeping around some boolean state (although it seems like the latter is covered by virtual devices in the new Rules system, iiuc.)

What do you think? Is there a clear best way to replicate this in the new architecture? Is it even possible?

I really appreciate any guidance.

If your pistons are somewhat complex, take a look at the SharpTools Rule Engine. Also look at the SharpTools community for guidance and examples. There are a fair number of participants there that are in the process of converting pistons to SharpTools rules. Plenty of help there with the process.