@Heizelmann @Yves911 @dk00000
Following the discussion on digital filter I have drafted a plugin which currently provides two simple filter types. For details see pimatic-filter. Please let me know what you think.
Digital Filter for Devices/Variables
@Heizelmann @Yves911 @dk00000
Following the discussion on digital filter I have drafted a plugin which currently provides two simple filter types. For details see pimatic-filter. Please let me know what you think.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
@mwittig : Might be an solution. In my opinion, a math expression applied directly to the original device or variable as I proposed above would be better than an additional device.
I just briefly looked at using pimatic-filter for my DHT11 sensors which only output integers, so it looks a bit choppy.
But got this in my log, not sure i made the device correctly.
11:23:30.583 [pimatic] error: A uncaught exception occured: TypeError: Cannot read property 'value' of undefined 11:23:30.583 [pimatic] error:> at SimpleMovingAverageFilter.Device.toJson (/home/pi/pimatic-app/node_modules/pimatic/lib/devices.coffee:173:30) 11:23:30.583 [pimatic] error:> at Framework.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic/lib/framework.coffee:492:37) 11:23:30.583 [pimatic] error:> at Namespace.<anonymous> (/home/pi/pimatic-app/node_modules/pimatic/lib/framework.coffee:492:35) 11:23:30.583 [pimatic] error:> at Namespace.EventEmitter.emit (events.js:95:17) 11:23:30.583 [pimatic] error:> at Namespace.emit (/home/pi/pimatic-app/node_modules/pimatic/node_modules/socket.io/lib/namespace.js:205:10) 11:23:30.583 [pimatic] error:> at /home/pi/pimatic-app/node_modules/pimatic/node_modules/socket.io/lib/namespace.js:172:14 11:23:30.583 [pimatic] error:> at process._tickCallback (node.js:415:13) 11:23:30.583 [pimatic] error:> This is most probably a bug in pimatic or in a module, please report it! 11:23:30.597 [pimatic] warn: Keeping pimatic alive, but could be in an undefined state, please restart pimatic so soon as possible!
I take it the expression bit it supposed to match the input variable? And this creates a new variable $filter1.temperature?
"devices"
{
"id": "homeduino-temperature",
"name": "Office Temp/DHT",
"class": "HomeduinoDHTSensor",
"type": 11,
"pin": 13,
"interval": 300000
},
{
"class": "SimpleMovingAverageFilter",
"id": "filter1",
"name": "Filter1",
"size": 5,
"output": {
"name": "temperature",
"label": "Temperature",
"expression": "$homeduino-temperature.temperature",
"acronym": "T",
"type": "number",
"unit": "°C"
}
},
@beikeland Unfortunately, I am not able to reproduce the error, but from analyzing the stack trace, I think it is a race condition. It may occur when the expression is evaluated for the first time while the device has not been fully initialized. Thus, I have changed the initialization to make sure the device is fully initializated before the evaluation takes place.
I have published a new release of the package.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
I’ll report back when i get a chance to test it. Holiday mode now
Works like a charm now! Thanks!!
Not goin to bother buying more expensive sensors now
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
</holiday mode>
Just tried to make some filters to use for my esp8266 nodes, implemented as VariablesDevices. But the filter does not like the devices as they lack getTemperature() and getHumidity(). Is this a limitation, or am i just doing it wrong?
"devices": [
{
"id": "esp01",
"name": "Bedroom Temp/esp",
"class": "VariablesDevice",
"variables": [
{
"name": "Temperature",
"expression": "$esp01-tem",
"type": "number",
"unit": "°C"
},
{
"name": "Humidity",
"expression": "$esp01-hum",
"type": "number",
"unit": "%"
},
{
"name": "Uptime",
"expression": "$esp01-upt",
"type": "number"
}
]
},
{
"class": "SimpleMovingAverageFilter",
"id": "esp01-filter",
"name": "Bedroom Temp/esp-Filter1",
"size": 5,
"output": {
"name": "humidity",
"label": "Humidity",
"expression": "$esp01-hum",
"acronym": "H",
"type": "number",
"unit": "%"
}
},
{
"class": "SimpleMovingAverageFilter",
"id": "esp01-filter2",
"name": "Bedroom Temp/esp-Filter2",
"size": 5,
"output": {
"name": "temperature",
"label": "Temperature",
"expression": "$esp01-tem",
"acronym": "T",
"type": "number",
"unit": "°C"
}
}
....
"variables": [
{
"name": "esp01-hum",
"value": 95
},
{
"name": "esp01-upt",
"value": 1834
},
{
"name": "esp01-tem",
"value": 17
},
and the associated log output:
21:14:58.843 [pimatic] info: New device "Bedroom Temp/esp-Filter1"...
21:14:58.862 [pimatic] error: Error loading device esp01-filter: Method getTemperature of Bedroom Temp/esp-Filter1 does not exist!
21:14:59.064 [pimatic] info: New device "Bedroom Temp/esp-Filter2"...
21:14:59.076 [pimatic] error: Error loading device esp01-filter2: Method getHumidity of Bedroom Temp/esp-Filter2 does not exist!
21:15:00.629 [pimatic] info: New device "System"...
change your expression to $device.attribute so maybe this expression will work $esp01-tem.value
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebook
make it so !
Didn’t seem to have any effect. Although, I’ve “cheated” and implemented a filter in the ESP8266 sensor node.