Page 44 of 86

Re: homebridge-edomoticz Plugin

Posted: Monday 17 October 2016 21:23
by bearded
Sorry to ask what is probably a 'schoolboy' question, but can you launch homebridge from a windows CMD shell successfully? running windows 10, I use 'node homebridge' in the appropriate directory and it loads all of my Domoticz accessories but doesn't respond at all beyond that. If I run it in the GIT-CMD shell (as an administrator) it runs fine.
I'm trying to simply run it from a batch file from startup along with Domoticz so that when homebridge freezes (which it seems to quite often since I've updated to iOS10) Myself (or my wife) can simply re-boot the mini-pc.

Thanks in advance!

Re: homebridge-edomoticz Plugin

Posted: Monday 17 October 2016 22:18
by Marci
No idea I'm afraid... I run all mine exclusively on raspberry Pi. Slack or the GitHub issues page would be best place to look: https://github.com/nfarina/homebridge/b ... /README.md

Presume you've done...
8.1 - If iOS apps cannot pair to HomeBridge, you may need to add a firewall rules to allow port 51826 (Control Panel > System Security > Windows Firewall > Advanced Settings > Create New Rule to allow TCP 51826)
...from https://github.com/nfarina/homebridge/w ... on-Windows, ensuring you've done a general tcp port rule, rather than just allowing it to git-cmd?

When you run from batch, does the ccd window status reflect it's ended after displaying pin code? i.e.: batch has done it's job, when homebridge loads, it then ends rather than being run as a daemon in background via foreverjs or similar?

Re: homebridge-edomoticz Plugin

Posted: Monday 17 October 2016 23:16
by martijnm
Marci wrote:Which branch of the plugin are you using? There were some authentication fixes put in place in the mqtt-integration branch over on github... update to this first...

https://github.com/PatchworkBoy/homebri ... ntegration

Download and copy the contents over the top of the contents of your current homebridge-edomoticz folder... and update your config.json as per further down that page... leave mqttenable set to 0 to run the mqtt branch without mqtt.
Thanks for your advice Marci.

I decided to start all over with a new sd card with latest Jessie version, and used the instructions from https://github.com/PatchworkBoy/homebri ... stallGuide

After setting everything up, I loaded my Domoticz configuration from a backup. Then I checked if I could add HomeBridge to my HomeKit network, but it still doesn't find HomeBridge...

Is it possible that this problem was caused by running iOS 10.1 beta?

Code: Select all

# sudo systemctl status homebridge.service -l

* homebridge.service - HomeBridge Service
   Loaded: loaded (/lib/systemd/system/homebridge.service; enabled)
   Active: active (running) since ma 2016-10-17 23:07:54 CEST; 3min 5s ago
 Main PID: 748 (homebridge)
   CGroup: /system.slice/homebridge.service
           `-748 homebridge              

okt 17 23:08:00 domoticz homebridge[748]: [2016-10-17 23:08:00] [eDomoticz] Initializing eDomoticz platform...
okt 17 23:08:01 domoticz homebridge[748]: [2016-10-17 23:08:00] [eDomoticz] Fetching Domoticz lights and switches...
okt 17 23:08:01 domoticz homebridge[748]: [2016-10-17 23:08:01] Loading 0 accessories...
okt 17 23:08:01 domoticz homebridge[748]: Scan this code with your HomeKit App on your iOS device to pair with Homebridge:
okt 17 23:08:01 domoticz homebridge[748]:                        
okt 17 23:08:01 domoticz homebridge[748]:     ┌────────────┐     
okt 17 23:08:01 domoticz homebridge[748]:     │ 031-45-154 │     
okt 17 23:08:01 domoticz homebridge[748]:     └────────────┘     
okt 17 23:08:01 domoticz homebridge[748]:                        
okt 17 23:08:01 domoticz homebridge[748]: [2016-10-17 23:08:01] Homebridge is running on port 51826.

Re: homebridge-edomoticz Plugin

Posted: Monday 17 October 2016 23:27
by Marci
Doubt it...


In home app, head to location icon top left, home settings, select your home, scroll to bottom, remove home.
Stop homeBridge. Edit config.json, change the MAC address username slightly.

Delete contents of .homebridge/persist/ and .homebridge/accessories/

Start homeBridge.

Fire up Home app, ensure you give your new home a different name to last time.

See if it finds it then.......

Re: homebridge-edomoticz Plugin

Posted: Monday 17 October 2016 23:34
by Marci
Mazzokun wrote:I format and reinstall everything from the beginning.. I got this

Code: Select all

pi@raspberrypi:~ $ systemctl -l status homebridge

...

so in debug it works.. either no.. What? Why? :(  :|  :([/quote]

Ok. Step by step then... is homeBridge where the homeBridge.service file thinks it is? Does it exist in /usr/bin?

Re: homebridge-edomoticz Plugin

Posted: Monday 17 October 2016 23:45
by Marci
TheRamon wrote:@Marci:

Yeah, I ment caching locally in eDomoticzAccessory. Something like isOn = false, and update that value through the status JSON of Domoticz. Whenever iOS asks te status of that device, we return the isOn value of eDomoticzAccessory. That'd be instant. We now make a HTTP request to Domoticz first to ask what the status is, and return that one.
Yup... cool... and we should now look to move to MQTT::{"command": "getdeviceinfo", "idx": xxx } in preference to http (but functionality would still need to be there for http regardless).

EDIT: in fact, let's make MQTT gets the priority first, as that should be REALLY straightforward to implement and deploy... which resolves the entire issue for those using MQTT (tests via node-red are instantaneous response)... the cacheing then comes into play for the legacy http requests, which could potentially go into a file-based store. Plugin then queries this on homeBridge load, and triggers a full http update in background, just to speed up initial homeBridge load time... ???

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 0:06
by Mazzokun
Marci wrote:
Mazzokun wrote:I format and reinstall everything from the beginning.. I got this

Code: Select all

pi@raspberrypi:~ $ systemctl -l status homebridge

...

so in debug it works.. either no.. What? Why? :(  :|  :([/quote]

Ok. Step by step then... is homeBridge where the homeBridge.service file thinks it is? Does it exist in /usr/bin?[/quote] Thank you [b]very very very[/b]  much! It was in usr/[b]local[/b]/bin  :oops:

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 0:08
by Marci
*thumbs up*

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 9:12
by TheRamon
Marci wrote: Yup... cool... and we should now look to move to MQTT::{"command": "getdeviceinfo", "idx": xxx } in preference to http (but functionality would still need to be there for http regardless).

EDIT: in fact, let's make MQTT gets the priority first, as that should be REALLY straightforward to implement and deploy... which resolves the entire issue for those using MQTT (tests via node-red are instantaneous response)... the cacheing then comes into play for the legacy http requests, which could potentially go into a file-based store. Plugin then queries this on homeBridge load, and triggers a full http update in background, just to speed up initial homeBridge load time... ???
Sounds splendid!!
I'll try and setup something. Config var > use HTTP or MQTT. Full with ideas now.

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 12:30
by martijnm
Marci wrote:In home app, head to location icon top left, home settings, select your home, scroll to bottom, remove home.
Stop homeBridge. Edit config.json, change the MAC address username slightly.
Delete contents of .homebridge/persist/ and .homebridge/accessories/
Have done this, and it worked after rebooting my Raspberry Pi !

Thanks!

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 13:44
by ergofreiberg
Hi!

Would it be possible to add Domoticz built-in Security Panel to Homebridge. Currently I have my Paradox EVO192 linked to Security Panel and in Domoticz everyting is working fine. Is there any point in opening issue about this topic?

Regards,
Ergo

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 19:17
by Marci
Depends... is the security panel accessible via the domoticz json or MQTT API? No mention of it here: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 19:32
by ergofreiberg
Jep - it's internal interface. Currently using MQTT and Tertiush/ParadoxIP150 script to talk to my security system.

{
"ActTime" : 1476811451,
"ServerTime" : "2016-10-18 20:24:11",
"Sunrise" : "08:09",
"Sunset" : "18:04",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "Normal",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 1,
"HardwareName" : "Domoticz Internal",
"HardwareType" : "Domoticz Internal interface",
"HardwareTypeVal" : 67,
"HaveDimmer" : false,
"HaveGroupCmd" : false,
"HaveTimeout" : false,
"ID" : "148702",
"LastUpdate" : "2016-10-18 15:36:07",
"MaxDimLevel" : 0,
"Name" : "Security Panel",
"Notifications" : "false",
"PlanID" : "5",
"PlanIDs" : [ 5 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"Status" : "Normal",
"StrParam1" : "",
"StrParam2" : "",
"SubType" : "Security Panel",
"SwitchType" : "Security",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "Security",
"TypeImg" : "security",
"Unit" : 0,
"Used" : 1,
"XOffset" : "430",
"YOffset" : "192",
"idx" : "43"
}
],
"status" : "OK",
"title" : "Devices"
}

e.

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 19:33
by ergofreiberg
... and nvalues.

Disarm 0
Normal Delay 1
Alarm 2
Alarm Delayed 3
Motion 4
No Motion 5
Panic 6
Panic End 7
8
Arm Away 9
Arm Away Delayed 10
Arm Home 11
Arm Home Delayed 12
Disarm 13

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 19:41
by Marci
Cool - throw all that into a GitHub issue n' I'll take a look when I get chance...

Re: homebridge-edomoticz Plugin

Posted: Tuesday 18 October 2016 19:50
by ergofreiberg
Ok, thanks, will do that.

e.

Re: homebridge-edomoticz Plugin

Posted: Wednesday 19 October 2016 14:45
by TheRamon
Alrighty, have just refactored and moved about EVERYTHING. :mrgreen: :o :o

Requests are handled differently now. I have moved the baserequest, called in every function, to domoticz.js.

Domoticz.js is basically a class with a few convenient functions:
  • Domoticz.deviceStatus - A GET request to Domoticz asking the status. Formerly baserequest.get to this.status_url.
  • Domoticz.updateDeviceStatus - A PUT/POST request to Domoticz saving the new status. Formerly baserequest.put to url separately defined in each function.
  • Domoticz.updateWithURL - Same as Domoticz.updateDeviceStatus.
The above list might suggest there's two functions doing the same thing. The thing is though, I have also integrated MQTT into updateDeviceStatus. Whenever MQTT is unable to initialise in the beginning, updateDeviceStatus will fallback to updateWithURL.

Only thing left to do now is to integrate caching for eDomoticzAccessory, so that values are returned immediately whenever HomeKit asks for it.
We should probably also look at MQTT device polling in Domoticz.deviceStatus. Caveat here though is that MQTT returns minimal data.

E.g. Requesting the status of my Dimmer through MQTT:
Spoiler: show

Code: Select all

{
   "Battery" : 255,
   "RSSI" : 12,
   "dtype" : "Lighting 5",
   "id" : "000000",
   "idx" : 2,
   "name" : "Dimmer",
   "nvalue" : 1,
   "stype" : "LightwaveRF",
   "svalue1" : "0",
   "switchType" : "Dimmer",
   "unit" : 1
}
And through JSON:
Spoiler: show

Code: Select all

{
	"ActTime": 1476880937,
	"ServerTime": "2016-10-19 14:42:17",
	"Sunrise": "08:11",
	"Sunset": "18:33",
	"result": [{
		"AddjMulti": 1.0,
		"AddjMulti2": 1.0,
		"AddjValue": 0.0,
		"AddjValue2": 0.0,
		"BatteryLevel": 255,
		"CustomImage": 0,
		"Data": "On",
		"Description": "",
		"Favorite": 0,
		"HardwareID": 2,
		"HardwareName": "Dummydev",
		"HardwareType": "Dummy (Does nothing, use for virtual switches only)",
		"HardwareTypeVal": 15,
		"HaveDimmer": true,
		"HaveGroupCmd": true,
		"HaveTimeout": false,
		"ID": "000000",
		"Image": "Light",
		"IsSubDevice": false,
		"LastUpdate": "2016-10-19 13:38:59",
		"Level": 43,
		"LevelInt": 14,
		"MaxDimLevel": 32,
		"Name": "Dimmer",
		"Notifications": "false",
		"PlanID": "0",
		"PlanIDs": [0],
		"Protected": false,
		"ShowNotifications": true,
		"SignalLevel": "-",
		"Status": "On",
		"StrParam1": "",
		"StrParam2": "",
		"SubType": "LightwaveRF",
		"SwitchType": "Dimmer",
		"SwitchTypeVal": 7,
		"Timers": "false",
		"Type": "Lighting 5",
		"TypeImg": "dimmer",
		"Unit": 1,
		"Used": 1,
		"UsedByCamera": false,
		"XOffset": "0",
		"YOffset": "0",
		"idx": "2"
	}],
	"status": "OK",
	"title": "Devices"
}
As you can see, JSON Api returns far more data. In some cases we need this data. So we should probably look at a partial implementation of MQTT polling.

Re: homebridge-edomoticz Plugin

Posted: Wednesday 19 October 2016 16:05
by TheRamon
I have just implemented caching for switches with 'Characteristic.On'. (Get/set power state)

This means "normal switches" are cached now, and whenever opening up the HomeKit app (or Eve) they'll instantly be available.

See mqtt-integration.

Re: homebridge-edomoticz Plugin

Posted: Wednesday 19 October 2016 19:01
by Marci
Note on upgrading to the above...

Stop homebridge, perform a...

Code: Select all

sudo git pull origin


...in the homebridge-edomoticz folder, restart homebridge.

Now in Home or Eve, head to accessories and remove the bridge from your home, then re-add it again. You’ll then have to reconfigure your rooms etc.

@Ramon - stellar job d00d... words escape me! *applause* 8-) Instantaneous response times across the board for sets, gets, siri commands. Absolutely awesome.

Re: homebridge-edomoticz Plugin

Posted: Wednesday 19 October 2016 20:08
by bdormael
Marci wrote:Note on upgrading to the above...

Stop homebridge, perform a...

Code: Select all

sudo git pull origin


...in the homebridge-edomoticz folder, restart homebridge.

Now in Home or Eve, head to accessories and remove the bridge from your home, then re-add it again. You’ll then have to reconfigure your rooms etc.

@Ramon - stellar job d00d... words escape me! *applause* 8-) Instantaneous response times across the board for sets, gets, siri commands. Absolutely awesome.

I can't upgrade without removing and reconfiguring everything ?
This because it's a huge job to configure all my rooms again.


Verzonden vanaf mijn iPad met Tapatalk