Evening all. Been working on quite a significant set of enhancements over the last few days. These have now been published as a new test version that can be installed by clicking the link:
Unreal Battery Changes
The Unreal Battery device no longer requires you to specify a time-base - instead it remembers the time of each event and uses this to calculate the elapsed time since the last event. This is a more resilient approach since it supports recovery after a failure - for example if your Homey goes down for several minutes, the power added will be scaled by the amount of “lost” time rather a fixed time-base. A new capability reports the elapsed time between successive events.
It increases the flexibility of use of the Unreal Battery. In addition to using a timed heart-beat, the device can be driven by When X changes flow cards.
Notes
I have deliberately maintained compatibility with the old version by retaining the original When flow card. You can still specify a time-base but this is ignored by the app. This means your flows will continue to work with no noticeable difference.
There is a new When flow card that does not require the time-base parameter. You are encouraged to migrate to this new flow card as you maintain your flows.
Many capabilities in Homey do not have a When X changes flow card (I find this irksome). The Device Capabilities app is your friend. The Listen (Watch) flow card emulates a When X changes flow card and can be used for any capability on any device.
New Power Integrator Device
Too many devices provide a power capability, but fail to provide an equivalent energy capability, or provide an energy capability that is deficient in some way (daily energy in place of accumulated energy, for example). For me the need to integrate power over time, giving accumulated energy proved to be a consistent need that I solved repeatedly using Advanced Virtual Devices and Flows. The necessary flows are not trivial and need to be maintained.
In the spirit of the Unreal Battery, the Power Integrator is designed to meet this specific need. It takes Power readings from any device and updates both accumulated and daily energy totals.
It operates identically to the Unreal Battery, using a simple flow card to absorb power readings and to calculate energy from power and elapsed time. The device stores the time of each successive event and uses this to calculate the interval between events. Either timed or When X Changes flow cards can be used to trigger updates in the Power Integrator.
Example
The device representing my inverter provides a measure of power (House Load Power) consumed domestically (i.e. power not exported and not routed to charge the battery):
Here you can see the use of the Listen flow card from the Device Capabilities app. Every time House Load Power changes on the Inverter device, the power is integrated into the accumulated energy. The last capability on the Power Integrator device shows the time elapsed between the most recent two events.
Notes
You can change the Device Class through the device settings. For example, I have a Power Accumulator representing the power and energy generated by Solar Panels. By changing the Device Class to “Solar Panel” this device is correctly integrated into the Homey Energy Tab.