@snille in my case non-SSL connections don’t fail, only SSL ones. Any idea how to find which package might be missing or outdated? My coding skills are a bit rusty :D
Read the statement by Michael Teeuw here.
Posts
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@snille said in MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror:
curl -X GET -H “Authorization: Bearer VeRy-LoNg-API-ToKen” -H “Content-Type: application/json” http://ha-IP:8123/api/states
Same here … I get all states with the following URLs:
https://myhome.org:443/api/states
https://myhome/api/statesHowever, when I try to use the local IP I can’t and that is normal as the certificate is not for that domain:
pi@raspberrypi:~ $ curl -X GET -H "Authorization: Bearer long-token" -H "Content-Type: application/json" https://192.168.1.19:443/api/states curl: (7) Failed to connect to 192.168.1.19 port 443: Connection refused pi@raspberrypi:~ $ curl -X GET -H "Authorization: Bearer long-token" -H "Content-Type: application/json" https://192.168.1.19:8123/api/states curl: (60) SSL: no alternative certificate subject name matches target host name '192.168.1.19' More details here: https://curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
What is wierd though is that although using SSL, the default port is still 8123, however, the connection is secured
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@Snille I think that I found out what the issue might be (at least for my case). I turned on debugging and here is what popped-up:
0|MagicMirror | [19.02.2022 12:34.16.715] [ERROR] 0|MagicMirror | MMM-homeassistant-sensors ERROR: Error: certificate has expired 0|MagicMirror | at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34) 0|MagicMirror | at TLSSocket.emit (events.js:315:20) 0|MagicMirror | at TLSSocket._finishInit (_tls_wrap.js:936:8) 0|MagicMirror | at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12) { 0|MagicMirror | code: 'CERT_HAS_EXPIRED' 0|MagicMirror | } 0|MagicMirror | [19.02.2022 12:34.16.721] [ERROR] 0|MagicMirror | Whoops! There was an uncaught exception... 0|MagicMirror | [19.02.2022 12:34.16.727] [ERROR] 0|MagicMirror | TypeError: Cannot read property 'statusCode' of undefined 0|MagicMirror | at Request._callback (/home/pi/MagicMirror/modules/MMM-homeassistant-sensors/node_helper.js:22:77) 0|MagicMirror | at self.callback (/home/pi/MagicMirror/modules/MMM-homeassistant-sensors/node_modules/request/request.js:185:22) 0|MagicMirror | at Request.emit (events.js:315:20) 0|MagicMirror | at Request.onRequestError (/home/pi/MagicMirror/modules/MMM-homeassistant-sensors/node_modules/request/request.js:877:8) 0|MagicMirror | at ClientRequest.emit (events.js:315:20) 0|MagicMirror | at TLSSocket.socketErrorListener (_http_client.js:426:9) 0|MagicMirror | at TLSSocket.emit (events.js:315:20) 0|MagicMirror | at emitErrorNT (internal/streams/destroy.js:92:8) 0|MagicMirror | at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) 0|MagicMirror | at processTicksAndRejections (internal/process/task_queues.js:84:21)
The certificate is valid though:
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@snille I think you struck the same obstacle as me, mate :D My setup is a bit different as I am not using reverse proxy - it is either SSL or no SSL within the local network and outside of it.
I am looking at the JS code right now … it might have something to do with how the URL is structured as it might not cover both cases, but I have to confirm that. -
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@snille lol sorry to hear that. I managed to get it to work on my main HA instance by removing SSL from my HA configuration.yaml file:
However, that doesn’t suit my needs as I control my house through my phone over the Internet and I want SSL to be enabled. I am continuing testing. Will keep you posted.
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@snille what is the most up-to-date code repo? The one that I pulled from is https://github.com/theskyisthelimit/MMM-homeassistant-sensors.git
Could it be that I have an old code base? I tried with different ports, URL/IP, still the same and still no errors in both logs HA or MM …
EDIT: I tried with another HA instance that I have which doesn’t have SSL enabled and it worked, so now I need to figure out what the difference between the two are :)
Will keep you posted.
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@snille it stopped working after HA version 2021.10 when the API discovery feature was deprecated. I am running HA Supervised on one raspberry pi and MM on another raspberry pi in the same network.
Here is the config of the MM module:
{ module: 'MMM-homeassistant-sensors', position: 'top_right', config: { title: 'Сензори', rowClass: 'normal', host: "192.168.1.19", port: "8123", https: true, //I have SSL enables since my instance is exposed to the Internet token: "here_goes_my_token", values: [ { sensor: "sensor.bathroom_temp_temperature", name: 'Температура', icons: [{ "default": "thermometer" }] }, { sensor: "sensor.bathroom_temp_humidity", name: 'Влажност', icons: [{ "default": "water-percent" }] }, { sensor: "switch.bathroom_fan_1", name: 'Вентилатор 1', icons: [{ "on": "fan", "off": "fan-off" }], replace: [{ "on": "вкл.", "off": "изкл." }] }, { sensor: "switch.bathroom_fan_2", name: 'Вентилатор 2', icons: [{ "on": "fan", "off": "fan-off" }], replace: [{ "on": "вкл.", "off": "изкл." }] }, ] } },
Here is the changelog of HA 2021.10:
The API endpoint /api/discovery_info now only return blank values. This endpoint is scheduled to be removed in Home Assistant Core 2022.1. As a regular user of Home Assistant, this change should not affect you. (@ludeeus - #56097) (api docs)
In the past I was having issues with https and the local IP address and then I changed it to the DNS hostname blabla.duckdsn.org and the external port for https (443) and it was working fine until the /api/discovery_info endpoint was deprecated.
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
@snille I don’t see any errors in either MM or HA, however I am still getting Error fetching stats in the module front end. Any suggestions for additional places where I could look? I checked the config and all seems fine to me.
-
RE: MMM-HomeAssistant-Sensors (Development) - Show your HA Sensors on your Mirror
I have the same issue as some of the other users here “Error fetching stats” with no errors in MM or HA. I generated a new token and changed it in the config, still no luck.
What version of HA are you running?
It was working for me until HA 2021.10: https://forum.magicmirror.builders/topic/15751/mmm-homeassistant-sensors-stopped-working-after-ha-2021-10-update?_=1645122750604
-
RE: New 2-way mirror supplier - low prices and lead times
@tomster wow, just wow. Your setup looks gorgeous. Thank you very much for the thorough review. I have spoken to the mirror manufacturer and complained about the imperfect cut and they promised to calibrate their cutting machine. Can you tell us more.about your setup as MM doesn’t really have good smart home integration. I am using Home Assistant for my smart home backbone and until version 2021.8 I was able to stream sensor data to MM, but after the HA API has changed, I can’t find a decent MM plugin that works, so I would very much appreciate any advice.