Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

NooB doing something dumb I'm sure #19

Closed
xbmcnut opened this issue May 6, 2020 · 11 comments
Closed

NooB doing something dumb I'm sure #19

xbmcnut opened this issue May 6, 2020 · 11 comments

Comments

@xbmcnut
Copy link

xbmcnut commented May 6, 2020

Love the concept of this as we have no end of grief trying to get the iGrill to work on our IOS devices.

Having a bit of trouble getting it working though as I'm a bit of a noob when it comes to Linux. I have a config folder under /home/igrill and this path is defined in the igrill.service file. I'm running this on a Pi Zero W with Debian Stretch on it. Using it for Bluetooth scanning already for the Xiaomi plant gateway (maybe there is a conflict with that service?)

When I try running the code in the readme, I get this:

pi@raspberrypi-ble:/home/igrill $ ./monitor.py -c /home/igrill/config                                          Traceback (most recent call last):
  File "./monitor.py", line 8, in <module>
    from config import Config
  File "/home/igrill/config.py", line 1, in <module>
    from builtins import object
ImportError: No module named builtins

What does that mean? FYI: Successfully installed future-0.18.2

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

N.B All of my pip modules are installed using pip3. Is that going to work or do I need to reinstall pip versions?

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

OK, making some progress.
Ran python3 ./monitor.py -c config and now I get:


pi@raspberrypi-ble:/home/igrill $ python3 ./monitor.py -c config
2020-05-06 23:48:59,808 MainThread INFO: log_level set to: INFO
2020-05-06 23:48:59,997 MainThread ERROR: Config validation failed: Value of optional entry 'port' must be <class 'int'>, was <class 'str'>
2020-05-06 23:49:00,000 MainThread ERROR: Config validation failed: Value of optional entry 'keepalive' must be <class 'int'>, was <class 'str'>
Traceback (most recent call last):
  File "./monitor.py", line 58, in <module>
    main()
  File "./monitor.py", line 34, in main
    raise ValueError("Config found in directory {0} is not valid".format(options.config_directory))
ValueError: Config found in directory config is not valid
devices:
  - name:       'grill'                  # Unique name of the device
    type:       'igrill_mini'              # Supported devices: igrill_mini, igrill_v2, igrill_v3
    address:    'D4:81:CA:01:E7:B5'      # The MAC of the device
    topic:      'temperature'    # The topic to publish on. will have name and probe number appended: <topic>/<name>/probe{1..4}
    interval:   20  
#MQTT All values default to paho.mqtt.client defaults
mqtt:
  host:       '10.0.1.100'                   # Optional default 'localhost'
  port:       '1883'                                 # Optional default '1883'
  keepalive:  '60'                                   # Optional default '60'

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

OK, changed external mqtt host to mqtt:10.0.1.100 and commented out the port and keepalive and now this:

pi@raspberrypi-ble:/home/igrill $ python3 ./monitor.py -c config
2020-05-06 23:56:11,636 MainThread INFO: log_level set to: INFO
Traceback (most recent call last):
  File "./monitor.py", line 58, in <module>
    main()
  File "./monitor.py", line 39, in main
    devices = get_device_threads(config.get_config('devices'), config.get_config('mqtt'), run_event)
  File "/home/igrill/utils.py", line 131, in get_device_threads
    enumerate(device_config)]
  File "/home/igrill/utils.py", line 130, in <listcomp>
    return [DeviceThread(ind, mqtt_config, run_event, **d) for ind, d in
  File "/home/igrill/igrill.py", line 201, in __init__
    self.mqtt_client = utils.mqtt_init(mqtt_config)
  File "/home/igrill/utils.py", line 97, in mqtt_init
    mqtt_client.connect(**strip_config(mqtt_config, ['host', 'port', 'keepalive']))
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/lib/python3.5/socket.py", line 694, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.5/socket.py", line 733, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Stumped for now. For what's its worth, I can see and pair with my iGrill mini using sudo bluetoothctl no problem.

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

Whew...nutted it. There seems to be document inconstancies that cause much confusion. It is now working with the following MQTT config and the latest files pulled from the releases page.

#MQTT All values default to paho.mqtt.client defaults
mqtt:
  host:       '10.0.1.100'                   # Optional default 'localhost'
  port:       1883                                # Optional default '1883'
  keepalive:  60    

So there are no quotes around the port or keepalive and mqtt does not need to be appended to the host ip (at least in my case).

@xbmcnut xbmcnut closed this as completed May 6, 2020
@bendikwa
Copy link
Owner

bendikwa commented May 6, 2020

I am glad that you got it to work! 👍

Where did it say that you needed "mqtt" appended to the host IP?

-Bendik

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

Thanks for the reply. This # host: 'mqtt.example.com' is in the zip download for the master which confused me along with some chatter about that in the issues or forums somewhere. As I had to use mqtt appended to a host with magicmirror years ago, it threw me for a bit. I've posted a full walk-through on the HA forums. https://community.home-assistant.io/t/weber-igrill-2-integration-with-lovelace-ui/61880/129

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

Oooh, a question then. For the service file, would I need to amend ExecStart=/usr/bin/python to be ExecStart=/usr/bin/python3?

@xbmcnut
Copy link
Author

xbmcnut commented May 6, 2020

Having issues with the service file now. So if I run the script manualy it works but after a reboot, it's not starting.

pi@raspberrypi-ble:~ $ systemctl daemon-reload && systemctl enable igrill && systemctl start igrill
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password: Failed to reload daemon: Method call timed out

If I run sudo su then run the command again it works but when I exit back to the pi user and run systemctl is-active igrill, it alternates from activating to active and back to activating again. How do I debug that?

@xbmcnut xbmcnut reopened this May 6, 2020
@bendikwa
Copy link
Owner

bendikwa commented May 7, 2020

As you have probably figured out, you need to reference the python executable that you want the program to be run with. in your case it is ExecStart=/usr/bin/python3

I use sudo/root for all commands regarding systemd (like systemctl)
Is the actual igrill script restarting all the time, or is it just the output of systemctl is-active igrill that is alternating.

In the thread you keep mentioning that you encountered inconsistencies in the guide/docs, please help me by pointing these out, so others don't have to struggle. :-)

@xbmcnut
Copy link
Author

xbmcnut commented May 7, 2020

Thanks @bendikwa Got it working with Python3 as you've indicated. Seems there was a post on the HA forums I missed that I copied and that worked. Key changes are were no dedicated /config folder and locate the igrill folder under the /home/pi.

In regards the docs, just check each of the example files in the master and releases folders to ensure consistency.

FYI, I've got my Google Home in the kitchen announcing when the thermometer comes online and offline so we know it's working. Thanks for the integration! Working a treat now.

@xbmcnut xbmcnut closed this as completed May 7, 2020
@bendikwa
Copy link
Owner

bendikwa commented May 8, 2020

Happy to hear that you got it working. I'll soon do another release, so any example config will be updated.
Thanks for the feedback.

-Bendik

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants