999LV / BatteryLevel

Domoticz python plugin to display/log battery level of zwave devices
MIT License
9 stars 5 forks source link

Path to CWD is not guaranteed for Non RaspberryPi installs #2

Closed coolnovember closed 5 years ago

coolnovember commented 6 years ago

On a non-raspberry Pi install (basic ubuntu image), Domoticz may not always run the script in domoticz/ folder.

For example, on my machine, the CWD for this plugin.py returns /home//

This makes the search for the zwave config file break if you hardcode it as ("./Config/zwcfg_0x????????.xml")

coolnovember commented 6 years ago

I've made some changes to make the script figure out where it is located, and then find the Config folder and then then zwcfg file, but I don't fully understand how to make a pull request on github.

You can see the edits in my commit here: https://github.com/coolnovember/BatteryLevel/commit/3b0f0a2f49bf28201418547666320845abf3cbfe

Tested working on Domoticz Version: Domoticz V3.8160 (c)2012-2017 GizMoCuz Build Hash: 7c34639, Date: 2017-10-21 05:03:34

OS version DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

999LV commented 6 years ago

@coolnovember thanks for your suggestion. Seems you cannot make a pull request ? Pls confirm and otherwise I’ll include myself in a future version

coolnovember commented 6 years ago

Correct. I am unable to submit a pull request at this moment. The change is to make the following additions. You can see the code along with some logging print statements at my commit linked above.

script_file=os.path.realpath(__file__)
script_dir=os.path.dirname(script_file)
config_path=os.path.join(script_dir,"../../","Config")
config_path_clean=os.path.abspath(config_path)
controllers = glob.glob(os.path.join(config_path_clean,"./zwcfg_0x????????.xml"))