Jump to content

MyQ Error


Ryan321654

Recommended Posts

1 hour ago, Ryan321654 said:

MyQ node cannot connect anymore via API.  Log is showing error:

polyinterface:write: cannot import name 'choices'

Mine is connected and working.   Are you using the local or cloud polyglot?  What version is the nodeserver?  If local, is it running on Polisy or something else?  Can you fin the point that it quit working in the log?

Link to comment
Share on other sites

1 hour ago, Ryan321654 said:

MyQ node cannot connect anymore via API.  Log is showing error:

polyinterface:write: cannot import name 'choices'

Hi, Ryan. That error appears to have something to do with nodeserver instantiation and not access to MyQ via the API, but I can’t be sure from the small snippet. Can you post the log entries for the same timestamp from the NODESERVER log instead of the Polyglot log?

Link to comment
Share on other sites

I'm running into this same error, I am running Polyglot Version 2.2.10, Frontend Version: 2.2.9-5, and ISY Version: 5.3.0. Polyglot is locally hosted on a VM running Raspbian x86. MyQ nodeserver is 2.1.13, other nodeservers are working just fine. I have tried updating my username/password, the same info in the log below occurs regardless of the authentication settings. Let me know if there is anything else you need! Here is the nodeserver log:

2021-01-04 15:38:30,499 MainThread polyinterface      INFO     polylogger:set_basic_config: set_basic_config: enable=True level=30
2021-01-04 15:38:30,936 MainThread polyinterface      INFO     polyinterface:init_interface: Received Config from STDIN.
2021-01-04 15:38:30,937 MainThread polyinterface      INFO     __init__:<module>: UDI Polyglot v2 Interface 2.1.0 Starting...
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: Traceback (most recent call last):
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: File "./myq-poly.py", line 16, in <module>
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: from myqapi import MyQ, API_DEVICE_TYPE_GATEWAY, API_DEVICE_TYPE_OPENER, API_DEVICE_TYPE_LAMP, API_DEVICE_STATE_OPEN, API_DEVICE_STATE_CLOSED, API_DEVICE_STATE_STOPPED, API_DEVICE_STATE_OPENING, API_DEVICE_STATE_CLOSING, API_DEVICE_STATE_ON, API_DEVICE_STATE_OFF, API_LOGIN_BAD_AUTHENTICATION, API_LOGIN_ERROR, API_LOGIN_SUCCESS
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: File "/home/pi/.polyglot/nodeservers/MyQ/myqapi.py", line 12, in <module>
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: from random import choices
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: ImportError
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: :
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: cannot import name 'choices'
 

Link to comment
Share on other sites

On 1/4/2021 at 4:11 PM, JustinO said:

I'm running into this same error, I am running Polyglot Version 2.2.10, Frontend Version: 2.2.9-5, and ISY Version: 5.3.0. Polyglot is locally hosted on a VM running Raspbian x86. MyQ nodeserver is 2.1.13, other nodeservers are working just fine. I have tried updating my username/password, the same info in the log below occurs regardless of the authentication settings. Let me know if there is anything else you need! Here is the nodeserver log:

2021-01-04 15:38:30,499 MainThread polyinterface      INFO     polylogger:set_basic_config: set_basic_config: enable=True level=30
2021-01-04 15:38:30,936 MainThread polyinterface      INFO     polyinterface:init_interface: Received Config from STDIN.
2021-01-04 15:38:30,937 MainThread polyinterface      INFO     __init__:<module>: UDI Polyglot v2 Interface 2.1.0 Starting...
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: Traceback (most recent call last):
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: File "./myq-poly.py", line 16, in <module>
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: from myqapi import MyQ, API_DEVICE_TYPE_GATEWAY, API_DEVICE_TYPE_OPENER, API_DEVICE_TYPE_LAMP, API_DEVICE_STATE_OPEN, API_DEVICE_STATE_CLOSED, API_DEVICE_STATE_STOPPED, API_DEVICE_STATE_OPENING, API_DEVICE_STATE_CLOSING, API_DEVICE_STATE_ON, API_DEVICE_STATE_OFF, API_LOGIN_BAD_AUTHENTICATION, API_LOGIN_ERROR, API_LOGIN_SUCCESS
2021-01-04 15:38:31,019 MainThread polyinterface      ERROR    polyinterface:write: File "/home/pi/.polyglot/nodeservers/MyQ/myqapi.py", line 12, in <module>
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: from random import choices
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: ImportError
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: :
2021-01-04 15:38:31,020 MainThread polyinterface      ERROR    polyinterface:write: cannot import name 'choices'
 

I solved this issue, it was a problem with my version of Python. I have moved to a Docker container with Python3.8 and MyQ will now start, but I am getting a new error:

 

2021-01-08 17:26:10,123 Controller polyinterface DEBUG myq-poly:shortPoll: Updating node states in Controller.shortPoll()...
2021-01-08 17:26:10,123 Controller polyinterface DEBUG myqapi:getDeviceList: In getDeviceList()...
2021-01-08 17:26:10,123 Controller polyinterface DEBUG myqapi:_checkToken: In _checkToken()...
2021-01-08 17:26:10,292 Controller polyinterface WARNING myqapi:_call_api: Network/server error in HTTP GET in _call_api(): 400 Client Error: Bad Request for url: https://api.myqdevice.com/api/v5.1/Accounts//Devices
2021-01-08 17:26:10,292 Controller polyinterface WARNING myq-poly:updateNodeStates: getDeviceList() returned no devices.
 
Looks like I have an authentication issue, but my username and password work in the iOS app.
Link to comment
Share on other sites

@JustinO Good catch on the Python version issue. It looks like the random.choices() that was added to get around the last MyQ API change only works in Python 3.6 or better.

As to the latest API change, reverse engineering APIs from network traffic from the mobile app is above my paygrade, so I will just have to wait on the smarter people to work through it before I can change the nodeserver. This is really a shame that Chamberlain can't work and play well with others.

EDIT: Just to be clear, the issue with a new API hasn't hit everybody. My MyQ nodeserver still works properly (running in Polyglot Cloud). 

Link to comment
Share on other sites

I am running Polyglot on Debian 10 bare bones on an ESXi virtual machine.  I have upgraded Python to 3.8 and made changed the priority to use 3.8 instead of the default 2.7.  I still cannot get MyQ to start even after uninstalls and restarts of both Debian and Polyglot server.  I am running Polyglot version 2.2.10 ISY is 5.3.0 with version 2.1.13 of MYQ.  I have also uninstalled and re-installed from the store.  

Link to comment
Share on other sites

18 hours ago, Ryan321654 said:

I am running Polyglot on Debian 10 bare bones on an ESXi virtual machine.  I have upgraded Python to 3.8 and made changed the priority to use 3.8 instead of the default 2.7.  I still cannot get MyQ to start even after uninstalls and restarts of both Debian and Polyglot server.  I am running Polyglot version 2.2.10 ISY is 5.3.0 with version 2.1.13 of MYQ.  I have also uninstalled and re-installed from the store.  

If it is still failing on loading "choices" from random library, I don't really know how to help. Choices is defined in the standard Python library random since 3.6. I am afraid I don't know very much about Debian 10 or ESXi virtual machines or Python priorities - those are all above my paygrade. The nodeserver loads fine on Polyglot on RPi, Polisy, and Polyglot Cloud.

If you type "python3" at a command line, what version of Python starts? Once in the CLI, type "from random import choices" and tell me what it says.

Link to comment
Share on other sites

23 hours ago, Ryan321654 said:

I am running Polyglot on Debian 10 bare bones on an ESXi virtual machine.  I have upgraded Python to 3.8 and made changed the priority to use 3.8 instead of the default 2.7.  I still cannot get MyQ to start even after uninstalls and restarts of both Debian and Polyglot server.  I am running Polyglot version 2.2.10 ISY is 5.3.0 with version 2.1.13 of MYQ.  I have also uninstalled and re-installed from the store.  

I tried that too on my machine, and eventually gave up and went with a Docker container that only had Python 3.8 installed. I tried changing the reference to ‘/usr/bin/env python’ which was in the MyQ scripts to use python3.6 which didn’t have any effect. I also tried changing both the python, and python3 commands to point to python3.8, which also didn’t solve the problem. Every time I was able to test running a simple python script that included choices as both root and my local user pi, the script worked. However, whenever I tried to start up MyQ it seemed that it reverted back to using python2. The last thing I did was to change the MyQ scripts to use python3.8 directly instead of environment variables, which then complained about the polyglot packages not being installed. I tried repairing the python3.8 installation I had to include the polyglot packages but I then found that my pip3 had catastrophic issues and couldn’t continue. I decided to stop wasting my time trying to fix multiple installations of python and gave up on that VM. I’m sure with a bit more time a solution could have been found, I’m just not very proficient at troubleshooting python installations. Hopefully some of this information will help you if you don’t want to ditch your OS or installation. 

Link to comment
Share on other sites

Hey thanks all for the suggestions to try.  Randy, the python version I have is 3.5.3 the error is the same from the CLI

>>> from random import choices
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'choices'
>>>

Justin I will try Docker.  Any suggestions for where to start.  I am new to Docker.

Link to comment
Share on other sites

28 minutes ago, Ryan321654 said:

Hey thanks all for the suggestions to try.  Randy, the python version I have is 3.5.3 the error is the same from the CLI

>>> from random import choices
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'choices'
>>>

Justin I will try Docker.  Any suggestions for where to start.  I am new to Docker.

Hopefully I can point you in the right direction, Docker can be complicated if you are new to it, I only began learning it about a year ago. To make things easy, I use Portainer as a graphical interface to manage my containers.

For a Polyglot container, I used the DockerFile and docker-compose.yml from the UD Polyglot-v2 GitHub page (https://github.com/UniversalDevicesInc/polyglot-v2/tree/master/docker) as a start point.

The DockerFile is the instruction file for Docker on how to build an image. The docker build command will run all the commands in that DockerFile and create the entire image that will be used when you run the containers using the docker-compose.yml file. If you use Portainer, you can select Images and Build Image and copy/paste the DockerFile and it will create the image for you. Otherwise you may have to look up instructions on how to build the image.

I had to modify the DockerFile to make sure I got the latest version that I wanted, added a few python packages that were needed, and to make sure that python3.8 was being used. He is a copy of my DockerFile that works:

FROM node:10-alpine

EXPOSE 3000
WORKDIR /opt/polyglot-v2/

RUN apk add --no-cache --virtual .build-deps linux-headers build-base && \
    apk add --no-cache python3 python3-dev py3-pip bash git ca-certificates wget tzdata openssl musl-dev linux-headers gcc && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --upgrade pip setuptools wheel && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
    rm -r /root/.cache && \
    cd /opt && \
    git clone --depth=1 --single-branch --branch v2.2.10 https://github.com/UniversalDevicesInc/polyglot-v2.git && \
    cd /opt/polyglot-v2 && \
    npm install && \
    apk del .build-deps

VOLUME /usr/lib/python3.8/site-packages
VOLUME /root/.polyglot
VOLUME /root/.local

# Run Polyglot
CMD npm start

Once the image has been created, you can either add the docker-compose.yml to Portainer as a Custom Template and create a Stack from it or you will have to use docker-compose to launch the containers. Docker-compose is a separate install from Docker, but the Docker instructions for installation are quite good and include information on docker-compose as well. Here is my updated docker-compose file:

version: '2.4'
services:
    mongo:
        image: "mongo:latest"
        container_name: "mongodb"
        expose:
         - "27017"
        volumes:
          - /opt/polyglot/db:/data
          - /opt/polyglot/db/configdb:/data/configdb
          - /opt/polyglot/db/db:/data/db
        restart: always
    polyglot:
        stdin_open: true
        tty: true
        image: "polyglot-v2:v2.2.10"
        container_name: "polyglot-v2"
        ports:
         - "3000:3000"
         - "1883:1883"
        volumes:
         - /opt/polyglot/config:/root/.polyglot
         - polyglot-pkgs:/usr/lib/python3.8/site-packages
         - polyglot-pkgs:/root/.local
        links:
         - mongo
        depends_on:
         - mongo
        environment:
         - PYTHON=/usr/bin/python
         - PYTHON3=/usr/bin/python3
         - NODE_ENV=development
         - USEDOCKER=true
        restart: always

volumes:
  polyglot-pkgs:

This file will create two containers, one for the mongoDB, the other for polyglot based on the image you previously created. The changes I made saves the database files to my host machine at /opt/polyglot/db and the config files for polyglot at /opt/polyglot/config instead of using a volume. The python files are stored in a volume called polyglot-pkgs. I also had to expose port 1883 for MQTT in order for the interface to connect properly.

 

Hopefully that gets you started, if you have any questions please let me know!

Link to comment
Share on other sites

1 hour ago, Ryan321654 said:

Hey thanks all for the suggestions to try.  Randy, the python version I have is 3.5.3 the error is the same from the CLI

>>> from random import choices
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'choices'
>>>

Justin I will try Docker.  Any suggestions for where to start.  I am new to Docker.

Well, there you go. Python 3.6 or better is required. Python 3.6 was released over 4 years ago and has end-of-life at the end of this year, so it's not an outrageous requirement. It is the oldest version of Python still supported (except 2.7).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...