arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
466 stars 103 forks source link

Crashing my whole system.... Cant pull logs... #255

Closed JimmyEyeball closed 4 years ago

JimmyEyeball commented 4 years ago

This has me completely lost. I can get everything up and running all looking good, all tests fine but if I leave the system idle for a few hours... then if I go to back to check the status the whole system locks up and the only way to recover is to pull the power and hard reset the system so I can't even pull logs I have never had an issue like this before but I'm assuming that its an issue with my config can someone please give it the once over and tell me if they think this is where my issue is coming from PLEASEEEE....

{ "bridge": { "name": " HomebridgeMQTT", "username": "0E:53:6D:8E:09:09", "port": 44409, "pin": "999-99-999" }, "description": "HomebridgeMQTT", "platforms": [], "accessories": [{ "description": "POW.", "accessory": "mqtt-power-consumption-log-tasmota", "name": "POW", "url": "mqtt://192.168.1.173", "username": "1111", "password": "1111", "topics": { "statusGet": "stat/POW/POWER", "statusSet": "cmnd/POW/power", "energyGet": "tele/POW/SENSOR", "stateGet": "tele/POW/STATE" }, "onValue": "ON", "offValue": "OFF", "outletInUseBy": "current", "outletInUseCurrent": "1.65", "totalPowerResetBy": "month", "activityTopic": "tele/POW/LWT", "activityParameter": "Online", "startCmd": "cmnd/POW/TelePeriod", "startParameter": "15", "patchToSave": "/root/.homebridge/", "savePeriod": "15", "timeOffset": "-60", "manufacturer": "ITEAD", "model": "Sonoff POW", "serialNumberMAC": "84:F3:EB:3E:4E:03" }, { "accessory": "mqttthing", "type": "motionSensor", "name": "Motion Sensor F9754E", "url": "mqtt://192.168.1.173", "username": "1111", "password": "1111", "caption": "Test Motion Sensor F9754E", "topics": { "getMotionDetected": { "topic": "tele/RF/RESULT", "apply": "return( ( JSON.parse(message).RfReceived.Data == 'F9754E' ) ? 1 : null);" } }, "integerValue": true, "turnOffAfterms": 2000, "history": true }, { "accessory": "mqttthing", "type": "contactSensor", "name": "Contact Sensor 45A8A9", "url": "mqtt://192.168.1.173", "username": "1111", "password": "1111", "caption": "Contact Sensor 45A8A9", "topics": { "getContactSensorState": { "topic": "tele/RF/RESULT", "apply": "return( ( JSON.parse(message).RfReceived.Data == '45A8A9' ) ? 1 : null);" } }, "integerValue": true, "resetStateAfterms": 20000, "history": true }] }

JimmyEyeball commented 4 years ago

PS. This is via a Sonoff RF Bridge using single state Sonoff contact and motion sensors.....

Once I remove mqtt-thing or disable the instance my system returns to normal operation...

arachnetech commented 4 years ago

Formatting your JSON (with jsonlint.com) to make it easier to read:

{
    "bridge": {
        "name": " HomebridgeMQTT",
        "username": "0E:53:6D:8E:09:09",
        "port": 44409,
        "pin": "999-99-999"
    },
    "description": "HomebridgeMQTT",
    "platforms": [],
    "accessories": [{
        "description": "POW.",
        "accessory": "mqtt-power-consumption-log-tasmota",
        "name": "POW",
        "url": "mqtt://192.168.1.173",
        "username": "1111",
        "password": "1111",
        "topics": {
            "statusGet": "stat/POW/POWER",
            "statusSet": "cmnd/POW/power",
            "energyGet": "tele/POW/SENSOR",
            "stateGet": "tele/POW/STATE"
        },
        "onValue": "ON",
        "offValue": "OFF",
        "outletInUseBy": "current",
        "outletInUseCurrent": "1.65",
        "totalPowerResetBy": "month",
        "activityTopic": "tele/POW/LWT",
        "activityParameter": "Online",
        "startCmd": "cmnd/POW/TelePeriod",
        "startParameter": "15",
        "patchToSave": "/root/.homebridge/",
        "savePeriod": "15",
        "timeOffset": "-60",
        "manufacturer": "ITEAD",
        "model": "Sonoff POW",
        "serialNumberMAC": "84:F3:EB:3E:4E:03"
    }, {
        "accessory": "mqttthing",
        "type": "motionSensor",
        "name": "Motion Sensor F9754E",
        "url": "mqtt://192.168.1.173",
        "username": "1111",
        "password": "1111",
        "caption": "Test Motion Sensor F9754E",
        "topics": {
            "getMotionDetected": {
                "topic": "tele/RF/RESULT",
                "apply": "return( ( JSON.parse(message).RfReceived.Data == 'F9754E' ) ? 1 : null);"
            }
        },
        "integerValue": true,
        "turnOffAfterms": 2000,
        "history": true
    }, {
        "accessory": "mqttthing",
        "type": "contactSensor",
        "name": "Contact Sensor 45A8A9",
        "url": "mqtt://192.168.1.173",
        "username": "1111",
        "password": "1111",
        "caption": "Contact Sensor 45A8A9",
        "topics": {
            "getContactSensorState": {
                "topic": "tele/RF/RESULT",
                "apply": "return( ( JSON.parse(message).RfReceived.Data == '45A8A9' ) ? 1 : null);"
            }
        },
        "integerValue": true,
        "resetStateAfterms": 20000,
        "history": true
    }]
}

I can't see anything obviously wrong with those two mqttthing accessories. Homebridge logs would be helpful. Can you not access them after restarting?

Is your system overloaded? Raspberry Pi? What model/specification? What else is it running? It might be worth setting up sar to see if you're running out of memory. https://www.linuxtechi.com/generate-cpu-memory-io-report-sar-command/ is a useful introduction if you're not familiar with this.

Can you isolate the cause to one or other of the mqttthing accessories by removing them individually?

JimmyEyeball commented 4 years ago

Good job thank you Ill do that over the next day or so and test and let you know below is the only logs I have been able to grab but there's not much to them...

This in on a dedicated Pi 3 only running Homebridge with about 10 plugins and the MQTT Broker...

04:24:41 raspberrypi homebridge[335]: [4/30/2020, 04:24:41] [Contact Sensor 45A8A9] read data from Contact Sensor 45A8A9 : {"firstEntry":0,"lastEntry":26,"usedMemory":26,"refTime":609874978,"initialTime":1588182178,"history":["noValue",{"time":1588182178,"setRefTime":1},{"time":1588182178,"status":1},{"time":1588182209,"status":0},{"time":1588182213,"status":1},{"time":1588182233,"status":0},{"time":1588182778,"status":0},{"time":1588183378,"status":0},{"time":1588188217,"status":1},{"time":1588188237,"status":0},{"time":1588188259,"status":0},{"time":1588188859,"status":0},{"time":1588189459,"status":0},{"time":1588190059,"status":0},{"time":1588190659,"status":0},{"time":1588191259,"status":0},{"time":1588191859,"status":0},{"time":1588192459,"status":0},{"time":1588193059,"status":0},{"time":1588193659,"status":0},{"time":1588194259,"status":0},{"time":1588194859,"status":0},{"time":1588196107,"status":0},{"time":1588199893,"status":0},{"time":1588200491,"status":0},{"time":1588201091,"status":0},{"time":1588201695,"status":0}]} Apr 30 04:24:41 raspberrypi homebridge[335]: [4/30/2020, 04:24:41] [Contact Sensor 45A8A9] History Loaded from Persistant Storage Apr 30 04:24:41 raspberrypi homebridge[335]: [4/30/2020, 04:24:41] [Motion Sensor F9754E] read data from Motion Sensor F9754E : {"firstEntry":0,"lastEntry":170,"usedMemory":170,"refTime":609875036,"initialTime":1588182236,"history":["noValue",{"time":1588182236,"setRefTime":1},{"time":1588182236,"status":1},{"time":1588182238,"status":0},{"time":1588182465,"status":1},{"time":1588182467,"status":0},{"time":1588182472,"status":1},{"time":1588182474,"status":0},{"time":1588182478,"status":1},{"time":1588182480,"status":0},{"time":1588182484,"status":1},{"time":1588182486,"status":0},{"time":1588182491,"status":1},{"time":1588182493,"status":0},{"time":1588182497,"status":1},{"time":1588182499,"status":0},{"time":1588182514,"status":1},{"time":1588182516,"status":0},{"time":1588182528,"status":1},{"time":1588182530,"status":0},{"time":1588182537,"status":1},{"time":1588182539,"status":0},{"time":1588182543,"status":1},{"time":1588182545,"status":0},{"time":1588182549,"status":1},{"time":1588182551,"status":0},{"time":1588182556,"status":1},{"time":1588182558,"status":0},{"time":1588182563,"status":1},{"time":1588182565,"status":0},{"time":1588182572,"status":1},{"time":1588182574,"status":0},{"time":1588182579,"status":1},{"time":1588182581,"status":0},{"time":1588182605,"status":1},{"time":1588182607,"status":0},{"time":1588182611,"status":1},{"time":1588182613,"status":0},{"time":1588182619,"status":1},{"time":1588182621,"status":0},{"time":1588182647,"status":1},{"time":1588182649,"status":0},{"time":1588182652,"status":1},{"time":1588182654,"status":0},{"time":1588182659,"status":1},{"time":1588182661,"status":0},{"time":1588182667,"status":1},{"time":1588182669,"status":0},{"time":1588182674,"status":1},{"time":1588182676,"status":0},{"time":1588182678,"status":1},{"time":1588182680,"status":0},{"time":1588182687,"status":1},{"time":1588182689,"status":0},{"time":1588182693,"status":1},{"time":1588182695,"status":0},{"time":1588182700,"status":1},{"time":1588182702,"status":0},{"time":1588182708,"status":1},{"time":1588182710,"status":0},{"time":158818271 Apr 30 04:24:41 raspberrypi homebridge[335]: 9,"status":1},{"time":1588182721,"status":0},{"time":1588182778,"status":0},{"time":1588183186,"status":1},{"time":1588183188,"status":0},{"time":1588183196,"status":1},{"time":1588183198,"status":0},{"time":1588183203,"status":1},{"time":1588183205,"status":0},{"time":1588183211,"status":1},{"time":1588183213,"status":0},{"time":1588183217,"status":1},{"time":1588183219,"status":0},{"time":1588183229,"status":1},{"time":1588183231,"status":0},{"time":1588183236,"status":1},{"time":1588183238,"status":0},{"time":1588183242,"status":1},{"time":1588183244,"status":0},{"time":1588183249,"status":1},{"time":1588183251,"status":0},{"time":1588183256,"status":1},{"time":1588183258,"status":0},{"time":1588183266,"status":1},{"time":1588183268,"status":0},{"time":1588183329,"status":1},{"time":1588183331,"status":0},{"time":1588183341,"status":1},{"time":1588183343,"status":0},{"time":1588183348,"status":1},{"time":1588183350,"status":0},{"time":1588183356,"status":1},{"time":1588183358,"status":0},{"time":1588183362,"status":1},{"time":1588183364,"status":0},{"time":1588183369,"status":1},{"time":1588183371,"status":0},{"time":1588183378,"status":0},{"time":1588183384,"status":1},{"time":1588183386,"status":0},{"time":1588183392,"status":1},{"time":1588183394,"status":0},{"time":1588183402,"status":1},{"time":1588183404,"status":0},{"time":1588183410,"status":1},{"time":1588183412,"status":0},{"time":1588183416,"status":1},{"time":1588183418,"status":0},{"time":1588183429,"status":1},{"time":1588183431,"status":0},{"time":1588183435,"status":1},{"time":1588183437,"status":0},{"time":1588187659,"status":1},{"time":1588187661,"status":0},{"time":1588187683,"status":1},{"time":1588187685,"status":0},{"time":1588187778,"status":1},{"time":1588187780,"status":0},{"time":1588188130,"status":1},{"time":1588188132,"status":0},{"time":1588188168,"status":1},{"time":1588188170,"status":0},{"time":1588188259,"status":0},{"time":1588188286,"status":1},{"time":1588188288,"status":0},{"time":1588188297,"status":1},{"time":1588188299, Apr 30 04:24:41 raspberrypi homebridge[335]: "status":0},{"time":1588188859,"status":0},{"time":1588189459,"status":0},{"time":1588190059,"status":0},{"time":1588190659,"status":0},{"time":1588191080,"status":1},{"time":1588191082,"status":0},{"time":1588191259,"status":0},{"time":1588191302,"status":1},{"time":1588191304,"status":0},{"time":1588191859,"status":0},{"time":1588191957,"status":1},{"time":1588191959,"status":0},{"time":1588191966,"status":1},{"time":1588191968,"status":0},{"time":1588192459,"status":0},{"time":1588193059,"status":0},{"time":1588193659,"status":0},{"time":1588194259,"status":0},{"time":1588194859,"status":0},{"time":1588196107,"status":0},{"time":1588199893,"status":0},{"time":1588200491,"status":0},{"time":1588201091,"status":0},{"time":1588201691,"status":0},{"time":1588204024,"status":1},{"time":1588204054,"status":0},{"time":1588205518,"status":0},{"time":1588210434,"status":1},{"time":1588210436,"status":0},{"time":1588211034,"status":0},{"time":1588211070,"status":1},{"time":1588211072,"status":0},{"time":1588211634,"status":0},{"time":1588212231,"status":1},{"time":1588212233,"status":0},{"time":1588212234,"status":0},{"time":1588212834,"status":0},{"time":1588212962,"status":1},{"time":1588212964,"status":0},{"time":1588213434,"status":0},{"time":1588214034,"status":0},{"time":1588214189,"status":1},{"time":1588214191,"status":0},{"time":1588214789,"status":0}]} Apr 30 04:24:41 raspberrypi homebridge[335]: [4/30/2020, 04:24:41] [Motion Sensor F9754E] History Loaded from Persistant Storage Apr 30 04:24:42 raspberrypi homebridge[335]: [4/30/2020, 04:24:42] [POW] JSON problem Apr 30 04:24:44 raspberrypi homebridge[335]: [4/30/2020, 04:24:44] [Motion Sensor F9754E] lastActivation time loaded Apr 30 04:24:44 raspberrypi homebridge[335]: [4/30/2020, 04:24:44] [Contact Sensor 45A8A9] lastActivation time loaded Apr 30 04:27:58 raspberrypi systemd[1]: Stopping Node.js HomeKit Server...

arachnetech commented 4 years ago

Did you find the problem? (Just noticed you've closed the issue.)

JimmyEyeball commented 4 years ago

Hi yes sorry for not updating.... So looks like a problem of my own making looks like I had just one too many Instances running so I had x9 Instances running using roughly 10% Memory each obviously causing my issues so I have cut them down to around 5 and this seems to have resolved the issue looks like I had just happened to split another instance off to run MQTT-Thing separately at the same time......

But you know the way it works fix 1 problem create another lol I have another open if you have any ideas...

https://github.com/arachnetech/homebridge-mqttthing/issues/257

arachnetech commented 4 years ago

Aha, great to know that’s all it was. Glad you fixed it!