I’ve got an electricity coin meter in the corner of my house that has an LED that flashes once per watt hour of electricity used.
I’ve been searching the forum, but I can’t find how to feed that data into openhab. I’m thinking of a simple photodiode circuit over the LED and feed the signal in to my raspberry pi. Can anyone point me in the direction of how to feed this data into openhab and then have it convert it into a current power reading and cumulative power consumption reading for the day?
If OpenHAB is tunnin on the Same RPi, you could have a look at the GPIO binding. Or you could wire the phototransistorbto an Arduino/ESP and connector that to OpenHAB with mqtt or even directly to the rest API.
I can feed the signal from the photo diode into the raspberry pi that openhab is running on without too much hassle. I’ve never done anything on raspberry pi before, only Arduino, so I guess I’ll have to look into key binding? And then I guess feeding that directly into openhab?
I’ll order an easy to wire light sensor, wait for it to arrive and have a play.
Is there a tutorial lurking somewhere that details things like completely custom data inputs? I’ve got a diy off grid solar panel setup and batteries that in the future I’d love to feed in things like battery voltage and total watt hours generated in the last day etc, so I guess I could apply the knowledge gained here to that in the near future.
I understand the raspberry pi doesn’t have any analogue inputs, so an intermediate ADC etc will be required of course.
So I’ve just to do the whole thing manually from start to end? I’m really surprised that there’s not a semi automated way to set this up. I would have thought that most smart homes have their mains power consumption being fed into the system.
So I’ve got the sensor hooked up to GPIO pin4 and have created a Contact which succesfully goes from “closed” to “open” when I shine a torch on it. I’ve also set up a widget in habpanel that shows “open” and “closed” when I shine the torch on it.
However today is my first ever day with a Raspberry Pi and also my first day ever using openhab, so I’m rather confused by how to set up the rules for increasing the number and making it persistent etc.
I’ve sucessfully created a number called “CurrentDayWattHours” as a starting point, but I can’t work out how to get it to increase by 1 everytime the contact changes state.
So far my code is:
rule "count_todays_pulses"
when CurrentDayWattHours.state == null
then CurrentDayWattHours = 0
when
Item Main_meter changed from OPEN to CLOSED
then
postUpdate(CurrentDayWattHours, CurrentDayWattHours.intValue + 1)
end
but I keep getting errors no matter what I try.
[6,2]: no viable alternative at input 'when'
[7,8]: no viable alternative at input 'Main_meter'
[7,32]: no viable alternative at input 'OPEN'
[7,40]: no viable alternative at input 'CLOSED'
2018-01-09 00:17:42.972 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Meter_reading.rules' has errors, therefore ignoring it: [2,7]: no viable alternative at input 'CurrentDayWattHours'
[6,2]: no viable alternative at input 'when'
[7,8]: no viable alternative at input 'Main_meter'
[7,32]: no viable alternative at input 'OPEN'
[7,40]: no viable alternative at input 'CLOSED'
rule "count_todays_pulses"
when
Item Main_meter changed from OPEN to CLOSED
then
var newValue = 0
if ((CurrentDayWattHours.state instanceof DecimalType) && ((CurrentDayWattHours.state as DecimalType).intValue() > 0)) {
newValue = (CurrentDayWattHours.state as DecimalType).intValue()
}
newValue = newValue + 1
CurrentDayWattHours.postUpdate(newValue)
end