Add INA226 usermod for reading current and power over i2c
This pull request introduces a new usermod for integrating the INA226 voltage, current and power sensors into WLED. It uses the wollewald/INA226_WE library to handle the wire stuff, and implements settings like (more options in readme):
- I2CAddress: The I2C address in decimal. Default is 64 (0x40).
- CheckInterval: Number of seconds between readings. This should be higher than the time it takes to make a reading, determined by the two next options.
- INASamples: The number of samples to configure the INA226 to use for a measurement. Higher counts provide more accuracy.
- INAConversionTime: The time to use on converting and preparing readings on the INA226. Higher times provide more precision.
- ShuntResistor: Shunt resistor value in milliohms. An R100 shunt resistor should be written as "100", while R010 should be "10".
- CurrentRange: Expected maximum current in milliamps (e.g., 5 A = 5000 mA).
It also implements MQTT publishing and HA discovery documents.
Images:
As this is likely to be used to measure currents and powers of the lights WLED controls, would it make sense to react to changes in the effects, on/off, brightness and then trigger a measurement, regardless of what interval is set?
F.ex. if I set the brightness to something new, then ~2 seconds later I get a measurement - even if I just got one on an interval of 60 seconds. Effects will always have the possibility of being dynamic, so it's not going to become more "true" because of this, but maybe more responsive.
If so, how would I hook into relevant events?
No notes? Wild. :)