PatchworkBoy / homebridge-edomoticz

Domoticz Homebridge-Plugin
Other
118 stars 43 forks source link

excludeddevices not working? #118

Closed adrianmihalko closed 6 years ago

adrianmihalko commented 6 years ago

Hi,

I added excludedDevices (Setup-Devices, ID column), but they are still appearing in the Homekit app.

What I am doing wrong?

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:12",
        "port": 51826,
        "pin": "031-33-123"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "mqtt": 0,
            "excludedDevices": ["00082026","14083","00014076","02020809","00014066","00014064","0001408B","00014082","00082060","02020208","82043","00082044","1407D","1407E","00082047","82062","00082063","00082064","1408D","00082056","14085","82054","00082055","14077","82040","00082041","00082042","00014092","00014091","00082030","1406C","14080","0001405A","0389DBF2","148702","0014065","82005"]
        }
    ],
    "accessories": []
}
harmjanr commented 6 years ago

@adrianmihalko I don't use the excludedDevices, so can't tell what you are doing wrong. I use an easier way to filter the devices exposed to HomeKit:

Create a Room in Domoticz (Setup -> More Options -> Plan -> Roomplan) Add the devices that you want to expose to HomeKit to that room In the config.json, change the roomid from 0 to the ID of the created room Does this work out for you?

sfeakes commented 6 years ago

I have just encountered the same problem.

@harmjanr That's not easier depending on setup. I have ~90 devices and only want to exclude 4. Adding 4 to a list is a lot easier than adding 86.

PatchworkBoy commented 6 years ago

Please test with latest version (2.1.1 via npmjs) and report whether issue still exists...

ooii commented 6 years ago

I'm facing the same issue but not with all the devices. Some of the devices in the excludeDevices list are actually excluded but some are still exposed. And I'm running 2.1.1.

PatchworkBoy commented 6 years ago

I suspect the devices need to be excluded from first-run to stop them landing the accessory cache. If you delete ~/.homebridge/accessories and restart, does it still list rogue devices?

ooii commented 6 years ago

I'll test again this evening and come back to you. Edit: I don't need to be at home to check that. So here is my test. I stop homebridge, I delete both persist and accessories folders, I update the homebridge-edomoticz plug-in to v2.1.2, then restart homebridge. Some of the devices in the excludeDevices list are still added by the plugin but not all of them. The excludedDiveces list counts 23 devices and 5 of them are still added.

PatchworkBoy commented 6 years ago

Now we need to inspect the JSON Output for those 5 devices...

ooii commented 6 years ago

Here it is:

  1. Clock of a Danfoss Thermostat
{
    "ActTime": 1517318565,
    "ServerTime": "2018-01-30 14:22:45",
    "Sunrise": "08:25",
    "Sunset": "17:43",
    "result": [{
        "AddjMulti": 1,
        "AddjMulti2": 1,
        "AddjValue": 0,
        "AddjValue2": 0,
        "BatteryLevel": 74,
        "CustomImage": 0,
        "Data": "Thursday 01:23",
        "DayTime": "3;1;23",
        "Description": "",
        "Favorite": 0,
        "HardwareID": 39,
        "HardwareName": "USB Blanche",
        "HardwareType": "OpenZWave USB",
        "HardwareTypeVal": 21,
        "HaveTimeout": false,
        "ID": "00001B01",
        "LastUpdate": "2018-01-30 06:27:46",
        "Name": "Thermostat Clock",
        "Notifications": "false",
        "PlanID": "0",
        "PlanIDs": [
            0
        ],
        "Protected": false,
        "ShowNotifications": true,
        "SignalLevel": "-",
        "SubType": "Thermostat Clock",
        "Timers": "false",
        "Type": "General",
        "TypeImg": "clock",
        "Unit": 1,
        "Used": 1,
        "XOffset": "0",
        "YOffset": "0",
        "idx": "1114"
    }],
    "status": "OK",
    "title": "Devices"
}
  1. Cumulated power consumption (2 devices) from Fibaro Power Plug

    {
    "ActTime": 1517318736,
    "ServerTime": "2018-01-30 14:25:36",
    "Sunrise": "08:25",
    "Sunset": "17:43",
    "result": [{
        "AddjMulti": 1,
        "AddjMulti2": 1,
        "AddjValue": 0,
        "AddjValue2": 0,
        "BatteryLevel": 255,
        "CounterToday": "0.250 kWh",
        "CustomImage": 0,
        "Data": "85.090 kWh",
        "Description": "",
        "Favorite": 0,
        "HardwareID": 39,
        "HardwareName": "USB Blanche",
        "HardwareType": "OpenZWave USB",
        "HardwareTypeVal": 21,
        "HaveTimeout": false,
        "ID": "00001101",
        "LastUpdate": "2018-01-30 14:12:02",
        "Name": "Conso Cumulée Salon",
        "Notifications": "false",
        "Options": "",
        "PlanID": "0",
        "PlanIDs": [
            0
        ],
        "Protected": false,
        "ShowNotifications": true,
        "SignalLevel": "-",
        "SubType": "kWh",
        "SwitchTypeVal": 0,
        "Timers": "false",
        "Type": "General",
        "TypeImg": "current",
        "Unit": 1,
        "Usage": "0.0 Watt",
        "Used": 1,
        "XOffset": "0",
        "YOffset": "0",
        "idx": "1056"
    }],
    "status": "OK",
    "title": "Devices"
    }

    and

    {
    "ActTime": 1517318788,
    "ServerTime": "2018-01-30 14:26:28",
    "Sunrise": "08:25",
    "Sunset": "17:43",
    "result": [{
        "AddjMulti": 1,
        "AddjMulti2": 1,
        "AddjValue": 0,
        "AddjValue2": 0,
        "BatteryLevel": 255,
        "CounterToday": "0.000 kWh",
        "CustomImage": 0,
        "Data": "14.710 kWh",
        "Description": "",
        "Favorite": 0,
        "HardwareID": 39,
        "HardwareName": "USB Blanche",
        "HardwareType": "OpenZWave USB",
        "HardwareTypeVal": 21,
        "HaveTimeout": false,
        "ID": "00001201",
        "LastUpdate": "2018-01-30 14:24:25",
        "Name": "Conso cumulée Grenier",
        "Notifications": "false",
        "Options": "",
        "PlanID": "0",
        "PlanIDs": [
            0
        ],
        "Protected": false,
        "ShowNotifications": true,
        "SignalLevel": "-",
        "SubType": "kWh",
        "SwitchTypeVal": 0,
        "Timers": "false",
        "Type": "General",
        "TypeImg": "current",
        "Unit": 1,
        "Usage": "0.0 Watt",
        "Used": 1,
        "XOffset": "0",
        "YOffset": "0",
        "idx": "1065"
    }],
    "status": "OK",
    "title": "Devices"
    }
  2. Current Power Consumption from a Fibaro power plug

    {
    "ActTime": 1517318847,
    "ServerTime": "2018-01-30 14:27:27",
    "Sunrise": "08:25",
    "Sunset": "17:43",
    "result": [{
        "AddjMulti": 1,
        "AddjMulti2": 1,
        "AddjValue": 0,
        "AddjValue2": 0,
        "BatteryLevel": 255,
        "CustomImage": 0,
        "Data": "52.4 Watt",
        "Description": "",
        "Favorite": 0,
        "HardwareID": 39,
        "HardwareName": "USB Blanche",
        "HardwareType": "OpenZWave USB",
        "HardwareTypeVal": 21,
        "HaveTimeout": false,
        "ID": "0001104",
        "LastUpdate": "2018-01-30 14:04:02",
        "Name": "Conso instantanée Salon",
        "Notifications": "false",
        "PlanID": "0",
        "PlanIDs": [
            0
        ],
        "Protected": false,
        "ShowNotifications": true,
        "SignalLevel": "-",
        "SubType": "Electric",
        "Timers": "false",
        "Type": "Usage",
        "TypeImg": "current",
        "Unit": 2,
        "Used": 1,
        "XOffset": "0",
        "YOffset": "0",
        "idx": "1054"
    }],
    "status": "OK",
    "title": "Devices"
    }

    and

    {
    "ActTime": 1517318880,
    "ServerTime": "2018-01-30 14:28:00",
    "Sunrise": "08:25",
    "Sunset": "17:43",
    "result": [{
        "AddjMulti": 1,
        "AddjMulti2": 1,
        "AddjValue": 0,
        "AddjValue2": 0,
        "BatteryLevel": 255,
        "CustomImage": 0,
        "Data": "0.0 Watt",
        "Description": "",
        "Favorite": 0,
        "HardwareID": 39,
        "HardwareName": "USB Blanche",
        "HardwareType": "OpenZWave USB",
        "HardwareTypeVal": 21,
        "HaveTimeout": false,
        "ID": "0001201",
        "LastUpdate": "2018-01-30 06:27:46",
        "Name": "Conso instantanée Grenier",
        "Notifications": "false",
        "PlanID": "0",
        "PlanIDs": [
            0
        ],
        "Protected": false,
        "ShowNotifications": true,
        "SignalLevel": "-",
        "SubType": "Electric",
        "Timers": "false",
        "Type": "Usage",
        "TypeImg": "current",
        "Unit": 2,
        "Used": 0,
        "XOffset": "0",
        "YOffset": "0",
        "idx": "1066"
    }],
    "status": "OK",
    "title": "Devices"
    }
PatchworkBoy commented 6 years ago

And lastly a copy of your config.json (removing any credentials, obvs)

ooii commented 6 years ago
{
        "bridge": {
                "name": "Homebridge-edomoticz",
                "username": "CC:21:3E:E4:DE:36",
                "port": 51828,
                "pin": "031-45-154"
        },
        "description": "Configuration file for (e)xtended Domoticz platform.",
        "platforms": [
                {
                        "platform": "eDomoticz",
                        "name": "eDomoticz",
                        "server": "192.168.1.11",
                        "port": "8080",
                        "ssl": 0,
                        "roomid": 0,
                        "mqtt": 1,
                        "excludedDevices":["0000001", "0002", "0000003", "0000071", "0000004", "00001101", "00001201", "0001104", "0001204", "00001B01"]
                }
        ]
}
PatchworkBoy commented 6 years ago

"Conso instantanée Grenier" isn't in your excludedDevices array in config.json (you have 00001201 but not 0001201)

ooii commented 6 years ago

I changed several times the config.json file so, the version I sent was not right. But I just added it, deleted the 2 folders and restarted homebridge and it is still there.

PatchworkBoy commented 6 years ago

OK - excludedDevices has been rewritten. Not entirely sure why whoever wrote that portion of code in the first place based it around a device’s ID because this is not a unique value (I have LOTS of devices in my set up that share the same ID value in Settings > Devices). Basically: The code in the plugin is correct, but will only function correctly when looking at a unique value for each device. The rest of the plugin uses the IDX value, so this is what it’ll be changed to.

I suspect this is the root cause of everyone’s issues when using excludeDevices in config.json.

Run an npm update on the plugin (to 2.1.4), remove accessories & persist, modify your config.json to use idx instead of id, launch, test and report back please.

PatchworkBoy commented 6 years ago

Note duplicate values in ID column:

duplicated
ooii commented 6 years ago

It seems OK. Thanks. I think you can close this one.

PatchworkBoy commented 6 years ago

Cool - thanks for reporting back.

nagubal commented 6 years ago

Works great, thank you!

adrianmihalko commented 6 years ago

For me it's still not working. I stopped homembridge.service, I upgraded plugin to 2.1.4. I deleted all devices (removed homebridge hub) from Homekit. I removed persist folder. I edited config.json:

$ cat config.json 
{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:99",
        "port": 51826,
        "pin": "123-34-321"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "mqtt": 0,
            "excludedDevices": ["91","11","27","92","30","6","28","50","76","77","78","83","79","80","81","86","68","87","60","74","1","4","88","2","90","89","93","34","59","84","65","43","44","45","46","47","64","61","62","63","21","85","82","38","51","69","70","71","72","73","67","23","56","53","54","55","39","40","41","42","48","58","49","22"]
        },

I readded Homebridge in Homekit, but I still see all my devices. :(

PatchworkBoy commented 6 years ago

Did you remove the ~/.homebridge/accessories folder? This is where the accessory cache sits. Since caching was added this folder is the crucial one to remove to get homebridge to re-detect devices from scratch.

adrianmihalko commented 6 years ago

Nope and the meantime I fond that this was the problem. It works fine now, thank you very much.