[userModule] Base Module (Updated 2017/01/22)

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Mike Yeager
Posts: 160
Joined: 03 May 2014 07:02

Re: [userModule] Base Module (Updated 2016/02/20)

Post by Mike Yeager » 03 Jun 2016 22:14

I didn't think about that. I guess updateTime would change if the icon were to be changed. I normally do things in Python but I'm learning to do more in Javascript. Code like yours is a great help when it comes to figuring things out. I'm starting to map out a method of tracking presence using motion sensors, light switches, and door locking/sensor events. Lot's of stuff to consider before you even begin to think about coding anything...

Mike Yeager
Posts: 160
Joined: 03 May 2014 07:02

Re: [userModule] Base Module (Updated 2016/02/20)

Post by Mike Yeager » 07 Jun 2016 23:26


I'm noticing in the logs that it appears quite a few things are being processed by BaseModule that don't call BaseModule. Is this intentional?


Posts: 103
Joined: 05 Apr 2014 11:21

Re: [userModule] Base Module (Updated 2016/02/20)

Post by maros » 15 Jun 2016 13:07

Yes this is intentional. Some of my modules using BaseModule rely on the modify:metrics:level events. The last value required to detect real level changes is handled by BaseModule for all devices
Z-Way 2.2.4 on Raspi B | My Zway GitHub repos | Amazon Wishlist to support module development

Mike Yeager
Posts: 160
Joined: 03 May 2014 07:02

Re: [userModule] Base Module (Updated 2016/02/20)

Post by Mike Yeager » 15 Jun 2016 20:05

Gotcha. I only noticed it because my system was getting sluggish and I was looking at possible reasons why. I was pretty sure that being I was running on an original RPi, that was the issue. I'm on a RPi 3 now and this thing FLIES!!! Keep up the excellent work...

Posts: 13
Joined: 07 Aug 2017 13:40

Re: [userModule] Base Module (Updated 2017/01/22)

Post by wavedoff » 31 Jan 2018 10:19

Line 82 of base module describes some code that should throw a warning when values change too much between updates, with a TODO of making it reject these values as well.

Code: Select all

    // Warn on big level changes - TODO maybe deny too big changes
    if (deviceType === 'sensorMultilevel') {
        var diff = Math.abs(lastLevel-newLevel);
        var probeType = vDev.get('metrics:probeType');
        // Ignore diff for changes of more than 4 hours
        if (modificationTime-lastUpdate > (4*60*60)) {
            diff = 0;
        if (
                (probeType == 'luminosity' && (diff > 250 || newLevel > 1000 || newLevel < 0)) ||
                (probeType == 'temperature' && (diff > 10 || newLevel > 50 || newLevel < -30)) ||
                (probeType == 'humidity' && (diff > 20 || newLevel > 100 || newLevel < 5)) ||
                (probeType == 'ultraviolet' && (diff > 4 || newLevel > 15 || newLevel < -1))
            ) {
            self.error('Unlikely '+probeType+' level change from '+lastLevel+' to '+newLevel+' for '+vDev.id);
I am experiencing this exact problem. I will occasionally get a humidity reading of over 1 million %, or a temperature reading of 1600f, or go from 72f to 16f. All of these readings last only for a single report before returning to normal. These wildly out of range values completely screw up the autoscaling of grafana.

When I go looking in the log files, I can find these events, but base module does not seem to be throwing up a warning message,
I'm not sure if this section of the code is not working, or if my logging is set to not record warnings.

Code: Select all

[2018-01-27 19:11:13.943] [D] [zway] SETDATA devices.31.data.lastReceived = 0 (0x00000000)
[2018-01-27 19:11:13.943] [D] [zway] SETDATA devices.31.instances.0.commandClasses.49.data.1.deviceScale = 1 (0x00000001)
[2018-01-27 19:11:13.944] [D] [zway] SETDATA devices.31.instances.0.commandClasses.49.data.1.scaleString = "°F"
[2018-01-27 19:11:13.944] [D] [zway] SETDATA devices.31.instances.0.commandClasses.49.data.1.val = 16.000000
[2018-01-27 19:11:13.944] [D] [zway] SETDATA devices.31.instances.0.commandClasses.49.data.1 = Empty
[2018-01-27 19:11:14.041] [I] [core] Notification: device-info (device-temperature): {"dev":"Living room Temperature","l":"16 °F","location":4,"customIcon":"flaticonset_14_15068088416114497.png"}
[2018-01-27 19:11:14.267] [I] [core] [BaseModule-22] Set lastLevel to 16 for ZWayVDev_zway_31-0-49-1 (was 71.7)
[2018-01-27 19:11:14.332] [I] [core] [InfluxDbStats-70] Update device ZWayVDev_zway_31-0-49-1
Do you have plans to update Base Module to reject these values, or is this something I should take on myself?
Please forgive my ignorance. I'm trying to teach myself programming with home automation, and this happens to be the most annoying problem I'm having right now, so this is where I'm starting out. (lucky you, huh? :oops: )

Any advice would be much appreciated. :)

Post Reply