rocket4321/nx584mqtt

nx584_server does not start

Closed this issue · 14 comments

getting errors after attempt to run nx584 server:
pi@Alarm:~ $ nx584_server --serial /dev/ttyS0 --baud 9600 --mqtt 192.168.1.XXX --username XXXX --password YYYY
Traceback (most recent call last):
File "/usr/local/bin/nx584_server", line 3, in
from nx584mqtt import main
File "/home/pi/.local/lib/python3.7/site-packages/nx584mqtt/main.py", line 10, in
from nx584mqtt import api
File "/home/pi/.local/lib/python3.7/site-packages/nx584mqtt/api.py", line 34, in
app = flask.Flask("nx584mqtt")
File "/usr/lib/python3/dist-packages/flask/app.py", line 370, in init
root_path=root_path
File "/usr/lib/python3/dist-packages/flask/helpers.py", line 884, in init
root_path = get_root_path(self.import_name)
File "/usr/lib/python3/dist-packages/flask/helpers.py", line 725, in get_root_path
return os.path.dirname(os.path.abspath(mod.file))
File "/usr/lib/python3.7/posixpath.py", line 378, in abspath
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Since it is a private github I installed as follows:
'pip3 install /home/pi/Desktop/nx584mqtt-main.zip'

any ideas why root path is an issue?

thanks for the work

Thanks for checking it out. I would try this, in folder of your local copy of the repo:

pip3 install -e .

Otherwise, I can upload to PyPi, since I've been using it for a few weeks now without any issues, and I seem to have the disconnect/reconnect recovery functional.

thanks for the quick replay, I tried 'pip3 install -e .' install, get the same errors as above when attempting to run nx584_server

little more exploring it appears that nx584mqtt is being installed in /home/pi/.local rather than /usr/local directory

pi@Alarm:/usr/local/bin $ cd /home/pi/.local
pi@Alarm:/.local $ ls
bin lib share
pi@Alarm:
/.local $ cd bin
pi@Alarm:/.local/bin $ ls
nx584_client nx584_server
pi@Alarm:
/.local/bin $ cd ..
pi@Alarm:/.local $ cd lib
pi@Alarm:
/.local/lib $ ls
python3.7
pi@Alarm:/.local/lib $ cd ..
pi@Alarm:
/.local $ cd share
pi@Alarm:/.local/share $ ls
applications desktop-directories gvfs-metadata
pi@Alarm:
/.local/share $

Hmm, depending on where you unpacked your local copy of the repo, that could be as designed. If a dev version of a package is installed, it's located in the folder or immediate subfolder or that calling path, so that multiple versions of the same exec can installed simultaneously.

Repo is now public.
I'll need to correct a few things about install now in my docs, but it should be a simpilier install for you if you just want a simple replacement.

https://pypi.org/project/nx584mqtt/0.1.2/

again thanks for the prompt followup

still stuck with the same error message when starting nx584_server
get same error following install by 'pip3 install nx584mqtt' or 'pip3 install -e .'
had to create readme.rd file to get install to work. My steps as follows and the error is the same as before when trying to start nx584_server

pi@raspberrypi:~/nx584mqtt-0.1.2 $ pip3 install -e .
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Obtaining file:///home/pi/nx584mqtt-0.1.2
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/nx584mqtt-0.1.2/setup.py", line 6, in
with open(path.join(this_directory, 'README.rd'), encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/nx584mqtt-0.1.2/README.rd'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /home/pi/nx584mqtt-0.1.2/
pi@raspberrypi:/nx584mqtt-0.1.2 $ vi README.rd
pi@raspberrypi:
/nx584mqtt-0.1.2 $ pip3 install -e .
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Obtaining file:///home/pi/nx584mqtt-0.1.2
Requirement already satisfied: paho-mqtt in /home/pi/.local/lib/python3.7/site-packages (from nx584mqtt==0.1.2) (1.5.1)
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (from nx584mqtt==0.1.2) (3.4)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from nx584mqtt==0.1.2) (2.21.0)
Installing collected packages: nx584mqtt
Running setup.py develop for nx584mqtt
Successfully installed nx584mqtt
pi@raspberrypi:/nx584mqtt-0.1.2 $ ls
LICENSE nx584_client nx584mqtt nx584mqtt.egg-info nx584_server PKG-INFO README.md README.rd setup.cfg setup.py
pi@raspberrypi:
/nx584mqtt-0.1.2 $ cd /usr/local/bin
pi@raspberrypi:/usr/local/bin $ ls
pi@raspberrypi:/usr/local/bin $ cd /home/pi/.local/bin
pi@raspberrypi:/.local/bin $ ls
nx584_client nx584_server
pi@raspberrypi:
/.local/bin $ ./nx584_server --config /home/pi/config.ini --serial /dev/ttyS0 --baud 9600 --mqtt 192.168.1.xxx --username xxx --password yyy
Traceback (most recent call last):
File "./nx584_server", line 7, in
exec(compile(f.read(), file, 'exec'))
File "/home/pi/nx584mqtt-0.1.2/nx584_server", line 3, in
from nx584mqtt import main
File "/home/pi/nx584mqtt-0.1.2/nx584mqtt/main.py", line 10, in
from nx584mqtt import api
File "/home/pi/nx584mqtt-0.1.2/nx584mqtt/api.py", line 34, in
app = flask.Flask("nx584mqtt")
File "/usr/lib/python3/dist-packages/flask/app.py", line 370, in init
root_path=root_path
File "/usr/lib/python3/dist-packages/flask/helpers.py", line 884, in init
root_path = get_root_path(self.import_name)
File "/usr/lib/python3/dist-packages/flask/helpers.py", line 725, in get_root_path
return os.path.dirname(os.path.abspath(mod.file))
File "/usr/lib/python3.7/posixpath.py", line 378, in abspath
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Yea, my bad. Looks like I rushed the release. Definitely a bug I'll need to work on. Will update in a day or two. Thanks for patience.

My attempts to try to make the http (flask) optional continue to make complications and frustration. If you're willing to try again, please do so with a fresh pull from pypi. However, do not include the '--listen' to your command line for now. Depending on your preferences, I may re-evaluate it's inclusion.

looks like you fixed it, great work!

all my alarm sensors show in mqtt explorer. In home assistant I was able to make mqtt binary sensors for both my door and motion sensors that give correct status and in home assistant I set up a mqtt alarm panel which appears to be working correctly requiring entry of code into the alarm panel each time to disarm. my mqtt alarm panel was set up as follows:

alarm_control_panel:

  • platform: mqtt
    command_topic: "home/alarm/set"
    state_topic: "home/alarm/partitions/1/state"
    command_template: "{{action}},1,{{code}}"
    code_arm_required: false
    code_disarm_required: true
    name: "nx584"
    retain: true
    code: xxxx
    where xxxx is my alarm code

nx584_client does not work to arm, disarm, or look at summary, its my understanding you have disabled this because of stability issues.

I use a modified mail.py program in the original pynx584 distribution ( posted in issue #38) to notify me by email and txt msg if alarm goes off. Ill test that tomorrow to confirm email notifications still works when wifey is away, she cant stand alarm tests going off.

Thanks for your help

still one issue, when I arm the alarm in stay mode, mqtt explorer reports it to be armed in away mode in home/alarm/partitions/1/state topic. This is problem since my automations using the alarm set in armed home mode are not working. Still otherwise a great job and thanks for all the work

Sorry to hear that. Both away and home work and display properly for me with the NX-8E.

To better examine your issue, and possible changes in alarm software/hardware I'm not aware of, I'd like to start by looking at what exactly is being displayed in the detailed data for your partition via MQTT explorer. Here's mine for compare.

Please confirm alarm mode change results by manually publishing to the mqtt topic, rather than using any Home Assistant interface for testing

Any differences for you (other than 'ARMED HOME' request produces 'armed_away') ?:

ARMED HOME:

Publish 
'ARM_HOME,1,None' 
to
'cmnd/nx584/action'

>> Result (practically immediate)

tele/nx584/partitions/1/state
becomes
armed_home

tele/nx584/partitions/1/conditions
becomes
['reserved', 'Armed', 'Instant', 'Silent exit enabled', 'Entryguard (stay mode)', 'Chime mode on', 'LED extinguish', 'Recent closing being timed', 'Reserved', 'Auto home inhibited', 'Sensor low battery', 'Ready to arm', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)']
ARMED AWAY:

Publish 
'ARM_AWAY,1,None' 
to
'cmnd/nx584/action'

>> Result
(after beep countdown and exit trigger)
(NOTE: if exit trigger is not performed, then alarm will go back to armed_home)
tele/nx584/partitions/1/state
becomes
armed_away

tele/nx584/partitions/1/conditions
becomes
['reserved', 'Armed', 'Chime mode on', 'LED extinguish', 'Recent closing being timed', 'Reserved', 'Sensor low battery', 'Ready to arm', 'Open period', 'Delay trip in progress (common zone)']

thanks for the quick response
checked again against your example above
either arming by mqtt explorer or manually arming by pushing physical alarm control panel I get the same results:

Publish 'ARM_HOME,1,None' to home/alarm/set
Results: home/alarm/partitions/1 shows:
conditions = ['Bypass code required', 'reserved', 'Armed', 'Silent exit enabled', 'Entryguard (stay mode)', 'Reserved', 'Sensor low
battery', 'Ready to arm', 'Cancel report is in the stack', 'Delay trip in progress (common zone)']
state = armed_away'

Publish 'ARM_AWAY,1,None' to home/alarm/set
Results: home/alarm/partitions/1 shows:
conditions = ['Bypass code required', 'reserved', 'Armed', 'Exit 1', 'Exit 2', 'Sensor low battery', 'Ready to arm', 'Delay trip in
progress (common zone)']
state = armed_away

I am using the default 'stateTopicRoot' and 'commandTopic' options for nx584_server

Alarm is set to proper away or home mode by mqtt command, but the status mqtt msg in home/alarm/partitions/1/state shows armed_away when the alarm is actually armed_home

Thanks for posting your responses. As I suspected, slight differences in our condition flags and poor assumption on my part have given me a clear place to fix. Let you know when you can try it again with a new version.

Thanks for being my beta tester!

v0.1.12 is available for your downloading pleasure

Great job, when I arm_home, mqtt now correctly reports alarm status is armed_home. Thanks for the prompt fix. Not aware of other problems, so this issue can close. Thanks