Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting an error #16

Open
jmayes2 opened this issue Dec 8, 2020 · 22 comments · Fixed by #20
Open

Getting an error #16

jmayes2 opened this issue Dec 8, 2020 · 22 comments · Fixed by #20
Labels
bug Something isn't working

Comments

@jmayes2
Copy link

jmayes2 commented Dec 8, 2020

Trying to use this on a very old software hub and getting this error on the cmd line for each detected device

'WARN async_failure, error: SimpleError { err: "Output does not match regex:'

no records appear to be going out to my broker.
Can I assume this is because of the old firmware (old apontest)

TX, J

@mikekap
Copy link
Owner

mikekap commented Dec 10, 2020

Hey there! Thanks for giving this a try. Indeed it seems like the aprontest binary you have outputs in a different format than the one with which I’m testing.

Could you paste the output of “aprontest -l” and “aprontest -l -m N” where “N” are all the device ids you see in the first command? I can roll out a fix pretty quickly after I have those!

@jmayes2
Copy link
Author

jmayes2 commented Dec 10, 2020 via email

@BobRyan530

This comment has been minimized.

@mikekap mikekap added the enhancement New feature or request label Dec 12, 2020
@mikekap
Copy link
Owner

mikekap commented Dec 12, 2020

Sorry for the duplicate post, just wanted to include formatted aprontest output:

[root@flex-dvt ~]# aprontest -l
Found 4 devices in database...
MASTERID |     INTERCONNECT |                         USERNAME
       1 |           ZIGBEE |                         LV_Lamp1
       2 |           ZIGBEE |                         LV_Lamp2
       3 |           ZIGBEE |                      Fireplace-L
       4 |           ZIGBEE |                      Fireplace-R

[root@flex-dvt ~]# aprontest -l -m 1
Device has 2 attributes...
LV_Lamp1
ATTRIBUTE |               DESCRIPTION |   TYPE | MODE |          GET |
     SET
        1 |                    On_Off | STRING |  R/W |           ON |
      ON
        2 |                     Level |  UINT8 |  R/W |            0 |
       0

[root@flex-dvt ~]# aprontest -l -m 2
Device has 2 attributes...
LV_Lamp2
ATTRIBUTE |               DESCRIPTION |   TYPE | MODE |          GET |
     SET
        1 |                    On_Off | STRING |  R/W |           ON |
      ON
        2 |                     Level |  UINT8 |  R/W |            0 |
      10

[root@flex-dvt ~]# aprontest -l -m 3
Device has 2 attributes...
Fireplace-L
ATTRIBUTE |               DESCRIPTION |   TYPE | MODE |          GET |
     SET
        1 |                    On_Off | STRING |  R/W |           ON |
      ON
        2 |                     Level |  UINT8 |  R/W |          254 |
     254

[root@flex-dvt ~]# aprontest -l -m 4
Device has 2 attributes...
Fireplace-R
ATTRIBUTE |               DESCRIPTION |   TYPE | MODE |          GET |
     SET
        1 |                    On_Off | STRING |  R/W |           ON |
      ON
        2 |                     Level |  UINT8 |  R/W |          254 |
     254

[root@flex-dvt ~]#

@mikekap
Copy link
Owner

mikekap commented Dec 13, 2020

This should be fixed in 0.1.4 - just re-run the installation command and let me know if you find any more issues!

@jmayes2
Copy link
Author

jmayes2 commented Dec 14, 2020 via email

@mikekap mikekap reopened this Dec 14, 2020
@mikekap
Copy link
Owner

mikekap commented Dec 14, 2020

That's unfortunate - sorry to hear that! Segmentation fault is pretty weird - wink-mqtt-rs doesn't use any unsafe code itself, so it's definitely a head scratcher.

Do you have any more information before the crash? Does anything get printed in the log file (/var/log/wink-mqtt-rs.log) at all? (e.g. INFO init_logger, min_log_level: Info or similar). If you do have some logging, could you try adding -vvv to the command line args (lives at /opt/wink-mqtt-rs/config) to print as much output as it can?

If there aren't any logs, if you could get a core dump, that would help. Try running ulimit -c unlimited before starting wink-mqtt-rs.

In theory the old firmware should be uninteresting for the actual binary - the binary completely statically linked and isolated from the host filesystem. As part of releasing 0.1.5 I did upgrade rust itself, so maybe that's the cause somehow?

@mikekap mikekap added bug Something isn't working and removed enhancement New feature or request labels Dec 14, 2020
@jmayes2
Copy link
Author

jmayes2 commented Dec 15, 2020

Sorry, I have been to busy to get back to you sooner. I made progress using my other hub (same firmware ver). No segmentation error now. I need to reinstall it again on the other hub, I think the file is corrupt. FYI this firmware does not support the install command you provided. The SSH is outdated plus TAR does not support the z option. I have to manually import the tar.gz then unzip and untar.

Now that it's running I get this in the log;

Jan 02 04:07:50.371 INFO init_logger, min_log_level: Info
Jan 02 04:07:50.372 INFO starting, version: 0.1.5
Jan 02 04:07:50.373 INFO opening_client, client_id: wink-mqtt-rs, port: 1883, h$
Jan 02 04:07:50.379 INFO poller_starting, resync_interval: 10000
Jan 02 04:07:50.508 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:50.810 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:50.884 INFO discovered_device, name: LV_Lamp1, id: 1
Jan 02 04:07:51.037 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:51.227 INFO discovered_device, name: LV_Lamp2, id: 2
Jan 02 04:07:51.267 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:51.491 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:51.498 INFO discovered_device, name: Fireplace-L, id: 3
Jan 02 04:07:51.776 INFO discovered_device, name: Fireplace-R, id: 4
Jan 02 04:07:51.784 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:52.029 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$
Jan 02 04:07:52.257 WARN loop_encountered_error, err: Io(Custom { kind: Invalid$

It continues with the loop_encountered_error error over and over.

Thankx again for working on this!
J

@mikekap
Copy link
Owner

mikekap commented Dec 16, 2020

hey @jmayes2 - I think you're using something that cuts off the output on the right. Could you try just using cat /var/log/wink-mqtt-rs.log to get the full output?

@mikekap
Copy link
Owner

mikekap commented Dec 16, 2020

Sorry for the spam, but could you test if this setup script works on your hub?

curl -L --cacert /etc/ssl/certs/ca-certificates.crt https://github.com/mikekap/wink-mqtt-rs/releases/latest/download/wink-mqtt-rs.tar.gz | gzip -d | tar -C / -xvf - && /opt/wink-mqtt-rs/setup.sh

If not, could bother you to try some of these commands so I know what's available?

wget --help
curl --help
gzip --help
gunzip --help
tar --help
tree /etc/ssl/

@jmayes2
Copy link
Author

jmayes2 commented Dec 16, 2020

Good news, I re-transferred the file to my 1st hub and no error, the log shows my devices were discovered and using mqtt monitor in home assistant I see the devices change state but no new devices in HA, is there some configuration I need to do in HA, load an add-on? (I used the prefix 'wink' ) I will get you the install info in a few. Thankx again, J

@jmayes2
Copy link
Author

jmayes2 commented Dec 16, 2020

When I run the new install line I get this...

[root@flex-dvt var]# curl -L --cacert /etc/ssl/certs/ca-certificates.crt https:/
/github.com/mikekap/wink-mqtt-rs/releases/latest/download/wink-mqtt-rs.tar.gz |
gzip -d | tar -C / -xvf - && /opt/wink-mqtt-rs/setup.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
gzip: invalid magic
tar: short read
[root@flex-dvt var]# curl -L --cacert /etc/ssl/certs/ca-certificates.crt https:/
/github.com/mikekap/wink-mqtt-rs/releases/latest/download/wink-mqtt-rs.tar.gz |
gzip -d | tar -C / -xvf - && /opt/wink-mqtt-rs/setup.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
gzip: invalid magic
tar: short read

@jmayes2
Copy link
Author

jmayes2 commented Dec 16, 2020

[root@flex-dvt var]# wget --help
BusyBox v1.22.1 (2014-03-26 18:26:55 EDT) multi-call binary.

Usage: wget [-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]
[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
[-U|--user-agent AGENT] [-T SEC] URL...

Retrieve files via HTTP or FTP

    -s      Spider mode - only check file existence
    -c      Continue retrieval of aborted transfer
    -q      Quiet
    -P DIR  Save to DIR (default .)
    -T SEC  Network read timeout is SEC seconds
    -O FILE Save to FILE ('-' for stdout)
    -U STR  Use STR for User-Agent header
    -Y      Use proxy ('on' or 'off')

[root@flex-dvt var]# curl --help
Usage: curl [options...]
Options: (H) means HTTP/HTTPS only, (F) means FTP only
--anyauth Pick "any" authentication method (H)
-a, --append Append to target file when uploading (F/SFTP)
--basic Use HTTP Basic Authentication (H)
--cacert FILE CA certificate to verify peer against (SSL)
--capath DIR CA directory to verify peer against (SSL)
-E, --cert CERT[:PASSWD] Client certificate file and password (SSL)
--cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)
--ciphers LIST SSL ciphers to use (SSL)
--compressed Request compressed response (using deflate or gzip)
-K, --config FILE Specify which config file to read
--connect-timeout SECONDS Maximum time allowed for connection
-C, --continue-at OFFSET Resumed transfer offset
-b, --cookie STRING/FILE String or file to read cookies from (H)
-c, --cookie-jar FILE Write cookies to this file after operation (H)
--create-dirs Create necessary local directory hierarchy
--crlf Convert LF to CRLF in upload
--crlfile FILE Get a CRL list in PEM format from the given file
-d, --data DATA HTTP POST data (H)
--data-ascii DATA HTTP POST ASCII data (H)
--data-binary DATA HTTP POST binary data (H)
--data-urlencode DATA HTTP POST data url encoded (H)
--delegation STRING GSS-API delegation permission
--digest Use HTTP Digest Authentication (H)
--disable-eprt Inhibit using EPRT or LPRT (F)
--disable-epsv Inhibit using EPSV (F)
--dns-servers DNS server addrs to use: 1.1.1.1;2.2.2.2
--dns-interface Interface to use for DNS requests
--dns-ipv4-addr IPv4 address to use for DNS requests, dot notation
--dns-ipv6-addr IPv6 address to use for DNS requests, dot notation
-D, --dump-header FILE Write the headers to this file
--egd-file FILE EGD socket path for random data (SSL)
--engine ENGINE Crypto engine (SSL). "--engine list" for list
-f, --fail Fail silently (no output at all) on HTTP errors (H)
-F, --form CONTENT Specify HTTP multipart POST data (H)
--form-string STRING Specify HTTP multipart POST data (H)
--ftp-account DATA Account data string (F)
--ftp-alternative-to-user COMMAND String to replace "USER [name]" (F)
--ftp-create-dirs Create the remote dirs if not present (F)
--ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)
--ftp-pasv Use PASV/EPSV instead of PORT (F)
-P, --ftp-port ADR Use PORT with given address instead of PASV (F)
--ftp-skip-pasv-ip Skip the IP address for PASV (F)
--ftp-pret Send PRET before PASV (for drftpd) (F)
--ftp-ssl-ccc Send CCC after authenticating (F)
--ftp-ssl-ccc-mode ACTIVE/PASSIVE Set CCC mode (F)
--ftp-ssl-control Require SSL/TLS for ftp login, clear for transfer (F)
-G, --get Send the -d data with a HTTP GET (H)
-g, --globoff Disable URL sequences and ranges using {} and []
-H, --header LINE Custom header to pass to server (H)
-I, --head Show document info only
-h, --help This help text
--hostpubmd5 MD5 Hex encoded MD5 string of the host public key. (SSH)
-0, --http1.0 Use HTTP 1.0 (H)
--http1.1 Use HTTP 1.1 (H)
--http2.0 Use HTTP 2.0 (H)
--ignore-content-length Ignore the HTTP Content-Length header
-i, --include Include protocol headers in the output (H/F)
-k, --insecure Allow connections to SSL sites without certs (H)
--interface INTERFACE Specify network interface/address to use
-4, --ipv4 Resolve name to IPv4 address
-6, --ipv6 Resolve name to IPv6 address
-j, --junk-session-cookies Ignore session cookies read from file (H)
--keepalive-time SECONDS Interval between keepalive probes
--key KEY Private key file name (SSL/SSH)
--key-type TYPE Private key file type (DER/PEM/ENG) (SSL)
--krb LEVEL Enable Kerberos with specified security level (F)
--libcurl FILE Dump libcurl equivalent code of this command line
--limit-rate RATE Limit transfer speed to this rate
-l, --list-only List only mode (F/POP3)
--local-port RANGE Force use of these local port numbers
-L, --location Follow redirects (H)
--location-trusted like --location and send auth to other hosts (H)
-M, --manual Display the full manual
--mail-from FROM Mail from this address (SMTP)
--mail-rcpt TO Mail to this/these addresses (SMTP)
--mail-auth AUTH Originator address of the original email (SMTP)
--max-filesize BYTES Maximum file size to download (H/F)
--max-redirs NUM Maximum number of redirects allowed (H)
-m, --max-time SECONDS Maximum time allowed for the transfer
--metalink Process given URLs as metalink XML file
--negotiate Use HTTP Negotiate Authentication (H)
-n, --netrc Must read .netrc for user name and password
--netrc-optional Use either .netrc or URL; overrides -n
--netrc-file FILE Set up the netrc filename to use
-N, --no-buffer Disable buffering of the output stream
--no-keepalive Disable keepalive use on the connection
--no-sessionid Disable SSL session-ID reusing (SSL)
--noproxy List of hosts which do not use proxy
--ntlm Use HTTP NTLM authentication (H)
--oauth2-bearer TOKEN OAuth 2 Bearer Token (IMAP, POP3, SMTP)
-o, --output FILE Write output to instead of stdout
--pass PASS Pass phrase for the private key (SSL/SSH)
--post301 Do not switch to GET after following a 301 redirect (H)
--post302 Do not switch to GET after following a 302 redirect (H)
--post303 Do not switch to GET after following a 303 redirect (H)
-#, --progress-bar Display transfer progress as a progress bar
--proto PROTOCOLS Enable/disable specified protocols
--proto-redir PROTOCOLS Enable/disable specified protocols on redirect
-x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port
--proxy-anyauth Pick "any" proxy authentication method (H)
--proxy-basic Use Basic authentication on the proxy (H)
--proxy-digest Use Digest authentication on the proxy (H)
--proxy-negotiate Use Negotiate authentication on the proxy (H)
--proxy-ntlm Use NTLM authentication on the proxy (H)
-U, --proxy-user USER[:PASSWORD] Proxy user and password
--proxy1.0 HOST[:PORT] Use HTTP/1.0 proxy on given port
-p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)
--pubkey KEY Public key file name (SSH)
-Q, --quote CMD Send command(s) to server before transfer (F/SFTP)
--random-file FILE File for reading random data from (SSL)
-r, --range RANGE Retrieve only the bytes within a range
--raw Do HTTP "raw", without any transfer decoding (H)
-e, --referer Referer URL (H)
-J, --remote-header-name Use the header-provided filename (H)
-O, --remote-name Write output to a file named as the remote file
--remote-name-all Use the remote file name for all URLs
-R, --remote-time Set the remote file's time on the local output
-X, --request COMMAND Specify request command to use
--resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS
--retry NUM Retry request NUM times if transient problems occur
--retry-delay SECONDS When retrying, wait this many seconds between each
--retry-max-time SECONDS Retry only within this period
--sasl-ir Enable initial response in SASL authentication
-S, --show-error Show error. With -s, make curl show errors when they occur
-s, --silent Silent mode. Don't output anything
--socks4 HOST[:PORT] SOCKS4 proxy on given host + port
--socks4a HOST[:PORT] SOCKS4a proxy on given host + port
--socks5 HOST[:PORT] SOCKS5 proxy on given host + port
--socks5-hostname HOST[:PORT] SOCKS5 proxy, pass host name to proxy
-Y, --speed-limit RATE Stop transfers below speed-limit for 'speed-time' secs
-y, --speed-time SECONDS Time for trig speed-limit abort. Defaults to 30
--ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)
--ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)
-2, --sslv2 Use SSLv2 (SSL)
-3, --sslv3 Use SSLv3 (SSL)
--ssl-allow-beast Allow security flaw to improve interop (SSL)
--stderr FILE Where to redirect stderr. - means stdout
--tcp-nodelay Use the TCP_NODELAY option
-t, --telnet-option OPT=VAL Set telnet option
--tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)
-z, --time-cond TIME Transfer based on a time condition
-1, --tlsv1 Use TLSv1 (SSL)
--trace FILE Write a debug trace to the given file
--trace-ascii FILE Like --trace but without the hex output
--trace-time Add time stamps to trace/verbose output
--tr-encoding Request compressed transfer encoding (H)
-T, --upload-file FILE Transfer FILE to destination
--url URL URL to work with
-B, --use-ascii Use ASCII/text transfer
-u, --user USER[:PASSWORD][;OPTIONS] Server user, password and login options
--tlsuser USER TLS username
--tlspassword STRING TLS password
--tlsauthtype STRING TLS authentication type (default SRP)
-A, --user-agent STRING User-Agent to send to server (H)
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
-w, --write-out FORMAT What to output after completion
--xattr Store metadata in extended file attributes
-q If used as the first parameter disables .curlrc
[root@flex-dvt var]# gzip --help
BusyBox v1.22.1 (2014-03-26 18:26:55 EDT) multi-call binary.

Usage: gzip [-cfd] [FILE]...

Compress FILEs (or stdin)

    -d      Decompress
    -c      Write to stdout
    -f      Force

[root@flex-dvt var]# gunzip -help
gunzip: invalid option -- 'h'
BusyBox v1.22.1 (2014-03-26 18:26:55 EDT) multi-call binary.

Usage: gunzip [-cft] [FILE]...

Decompress FILEs (or stdin)

    -c      Write to stdout
    -f      Force
    -t      Test file integrity

[root@flex-dvt var]# tar --help
BusyBox v1.22.1 (2014-03-26 18:26:55 EDT) multi-call binary.

Usage: tar -[cxthvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...

Create, extract, or list files from a tar file

Operation:
c Create
x Extract
t List
f Name of TARFILE ('-' for stdin/out)
C Change to DIR before operation
v Verbose
O Extract to stdout
h Follow symlinks
exclude File to exclude
X File with names to exclude
T File with names to include

[root@flex-dvt var]# tree /etc/ssl/
-sh: tree: not found
[root@flex-dvt var]#

@jmayes2
Copy link
Author

jmayes2 commented Dec 16, 2020

Lastly, the 2nd box that was giving me the errors in the log is not actually online with any devices so I think that may have caused the trouble, I have a feeling if I repair it to new devices it will work ok so I think your work is done other then the install. Thankx again for all the hard work! PS, lmk how to get HA to discover the wink MTQQ, if am sure it's just my being a dummy.

@mikekap
Copy link
Owner

mikekap commented Dec 16, 2020

For the old box, try this:

curl -k -L --cacert /etc/ssl/certs/ca-certificates.crt https://github.com/mikekap/wink-mqtt-rs/releases/latest/download/wink-mqtt-rs.tar.gz | gzip -d | tar -C / -xvf - && /opt/wink-mqtt-rs/setup.sh

Please try not to use it anywhere else - the only difference is -k which will disable the "actually make sure this binary is what I meant to download". Hackers and all could cheat you here.

For the hub that works, you do need to add some configuration on home assistant. Specifically, you need these lines in configuration.yaml: https://github.com/mikekap/raspberrypi/blob/master/home-assistant/configuration.yaml#L33-L36 . broker is the hostname that your mqtt server runs on - if it's the same machine as home assistant, you could try localhost.

That will work with the default discovery topic settings on the wink. If you're not using the defaults, you'll need to match the discovery prefix with the one on the wink - just add a discovery_prefix to the config above.

@jmayes2
Copy link
Author

jmayes2 commented Dec 16, 2020

Ok, both hubs working with that install line :) Funny thing, when monitoring mqtt and stopping/starting the your program I would see discovery information then status (repeating). After I did that a few times it stopped sending the discovery info so now that I have the yaml fixed in ha still no devices. I rebooted the hub but still it starts and only sends status. Any thoughts? If I manually set up a light in yaml what would be the topic, I tried brightness but that is not working.

@jmayes2
Copy link
Author

jmayes2 commented Dec 16, 2020

Ok, I duplicated this on both box's. After install I see on the mqtt monitor that when I start the program I get discovery information with '/home/wink/ID' prefix. I use the -t parm and put in 'homeassistant' which then yields '/homeassistantID', there is no '/' between homeassistant and the ID. (Again at this point discovery info is being sent). So I put in '-t homeassistant/' adding the missing slash. Now I get /homeassistant/ID like I should but discovery is no longer sent. As I did on the other box I took the new parms out and it went back to /home/wink/ID but still no discovery is sent, I can't get it to send discovery anymore on either box. Question?, is config information held anywhere else other the the config file in /opt/wink-mqtt-rs/? I can't figure out why it's no longer sending discovery info when I put it back to defaults.

@jmayes2
Copy link
Author

jmayes2 commented Dec 17, 2020

Putting auto discovery aside I am trying to manually add a light to HA via your mqtt, I can set level and turn on/off but status is not returning. This is the YAML I am using,

  • platform: mqtt
    name: "Living Room Lamp L"
    state_topic: "home/wink/5/1/status"
    command_topic: "home/wink/5/1/set"
    brightness_state_topic: "home/wink/5/2/status"
    brightness_command_topic: "home/wink/5/2/set"
    qos: 0
    payload_on: "ON"
    #on_command_type: 'brightness'
    payload_off: "OFF"
    optimistic: false

The mqtt status line looks like this;
home/wink/5/status {"level:255,"On_Off":"ON"}

Can you tell me what I need to put on the state topic lines?

Thankx again for all your help, J

@mikekap
Copy link
Owner

mikekap commented Dec 20, 2020

Hey @jmayes2 - let me try to answer those:

  • Discovery info is sent at startup and afterwards anytime home assistant sends a "boot" message on mqtt - which is specifically the birth & will messages described here. They are enabled by default in home assistant. If you want to simulate it with the mqtt cli, you can run mqtt pub --host raspberrypi --topic homeassistant/status --message online (replacing the mqtt host with your own of course).
  • The entirety of the configuration is in the config file. In fact, you can view the "live" configuration via ps aux | grep wink-mqtt-rs - the file is just used as command line arguments. You can read the full descriptions by running /opt/wink-mqtt-rs/wink-mqtt-rs --help. How are you restarting wink-mqtt-rs? Could there be multiple instances running that are colliding with each other? The easiest way to restart safely is to run /etc/rc.d/init.d/wink-mqtt-rs stop and wait a few seconds for the supervisor to start it again.
  • How are you monitoring the mqtt payloads? I use the mqtt cli and this is the command line you may want to use with the default topic: mqtt sub --host raspberrypi --topic 'homeassistant/#' -T. This is what I get when I restart wink-mqtt-rs on the hub:
homeassistant/light/wink_2/config: {"brightness_command_topic":"home/wink/2/3/set","brightness_scale":255,"brightness_state_topic":"home/wink/2/status","brightness_value_template":"{{value_json.Level}}","command_topic":"home/wink/2/3/set","name":"Bedroom Fan","on_command_type":"brightness","payload_off":"0","payload_on":"1","platform":"mqtt","state_topic":"home/wink/2/status","state_value_template":"{% if value_json.Level > 0 %}1{% else %}0{% endif %}","unique_id":"home/wink//2"}
  • For a manual configuration, I suggest pretty-printing that json above as:
{
    "brightness_command_topic": "home/wink/2/3/set",
    "brightness_scale": 255,
    "brightness_state_topic": "home/wink/2/status",
    "brightness_value_template": "{{value_json.Level}}",
    "command_topic": "home/wink/2/3/set",
    "name": "Bedroom Fan",
    "on_command_type": "brightness",
    "payload_off": "0",
    "payload_on": "1",
    "platform": "mqtt",
    "state_topic": "home/wink/2/status",
    "state_value_template": "{% if value_json.Level > 0 %}1{% else %}0{% endif %}",
    "unique_id": "home/wink//2"
}

You're very close in your config, but wink-mqtt-rs doesn't publish per-attribute status topics (though it could I suppose). Wink is also smart enough to toggle On_Off if you set level to anything above 0, so you don't need to do both.

@jmayes2
Copy link
Author

jmayes2 commented Dec 22, 2020

Thank you again, that was the template info I needed for the status response. I use the terminal in HA typing mosquitto_sub -u mqtt-username -P mqtt-pwd -v -t '#' to get a running response of all mqtt info, works nicely. Since I use mosquitto, would I still put 'blackberry' to identify the mqtt server in yaml?

I have things working well now but there is weirdness you should know about. After I tried putting in "homeassistant/" with the -t parm both of my installs stopped showing discovery, I know it does not make sense since only the config file has any settings but before I did that I was observing the discovery info each time I rebooted the program using mtqq.sh, now it just starts with status responses every 10 secs. Also when I reboot the mqtt broker or HA your program stops and needs to be restarted in the wink. I have reinstalled but no more discovery info is ever sent.

Lastly, using a zigbee GE bulb which supports parms 1&2 (state & brt) and using parm 1 as the state message something happens that causes a loop, the bulb works fine with brightness commands but once I send "off" the loop starts which spawns multiple apontest entries in the process list and ends up crashing the bulb. I have to stop the program, kill the extra aprontest process's and reset the bulb (kill power for a few secs) to get it working again. As a workaround I changed state to parm 2 (brt) which works fine as it sends a 0 for off and no loops, this info is just fyi.

After the holiday I will put a hub back to before the I used program (I have a backup of the flash and programmer) then run the sequence of events again and take some snapshots of the mqtt data for you to see. In the meantime I am up and running now with many thanks! Happy Holidays, J

@mikekap
Copy link
Owner

mikekap commented Dec 24, 2020

That seems like a reasonable command for doing mqtt listens. blackberry in the home assistant yaml sounds reasonable - honestly so long as home assistant sees ANY mqtt traffic, that part is probably not to blame.

I think the answer has been staring me in the face a little bit. Are you running two hubs with wink-mqtt-rs on both of them, on the same MQTT server? That will probably result in sporadic "liveness" on each of them (check /var/log/wink-mqtt-rs.log) - usually one would connect and the other would be in an infinite retry loop.

To try fix it, try changing the client_id of each hub. Specifically, in the mqtt connection config, instead of -s mqtt://foo try -s mqtt://foo?client_id=second-hub or something similar. The default client_id is wink-mqtt-rs and mqtt doesn't support multiple clients with the same id.

@jmayes2
Copy link
Author

jmayes2 commented Dec 24, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants