I believe I’ve followed the directions, but I’m getting this error when I attempt to run the MQTT module on my flic hub:
'Error' event
Error: Crashed
at [anon] (root/MQTT/main.js:230) preventsyield
This isn’t a particularly helpful error message since line 230 is just the error handling function. I modified the main.js values as such:
var server = "192.168.0.15";
var server_options = {
//"username": "",
//"password": "",
"port": 1883,
}
var hatopic = "homeassistant";
var flictopic = "flic";
var mqtt = require("./mqtt").create(server, server_options);
Does this look right? I don’t think I have a username/password on my MQTT broker and it is running on my HA at port 1883.
Update: I made a tiny modification to get the error message from the client.
mqtt.on('error', function (err) {
console.log('error', err);
setTimeout(function () {
throw new Error("Crashed")
}, 1000);
});
This got me:
Connection refused, NOT_AUTHORIZED.
So after poking around some more I realized I needed to enter my HOME ASSISTANT username and password!
Newbie here. For the life of me can’t get this to work. Any help much appreciated. Followed all the step diligently and stuck with the below error which I see some other users are also facing.
‘Error’ event
Error: Crashed
at [anon] (root/MQTT/main.js:230) preventsyield
Sorry my priorities are elsewhere right now. If someone has a fix and wants to submit a merge request, I’m happy to do that. Just have no time to debug anything right now.
Actually, I think that fork mentioned above might be the way to go! It looks like @asosnovsky has done a full refactor and blows my early attempt out of the water.
Any chance anyone has and idea of increasing bluetooth range of the hub using an ESP32?
Also, if we use Flicd add-on, can we directly connect it with out the hub and in that case take advantage of using the ESP32 as a Bluetooth proxy to extend range?
The integration did scan most of my buttons (I guess only the ones who had remaining battery life).
Which is why I did change the battery in a button which is currently not available in HASS → MQTT.
As far as I understand the manual (Flic - Home Assistant) I have to start the discovery mode through the configuration.yaml file… but I don’t know exactly how.
My config.yaml file currently shows the following data:
# Loads default set of integrations. Do not remove.
default_config:
recorder:
db_url: mysql://homeassistant:xxxxxxx@core-mariadb/homeassistant?charset=utf8mb4
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
Do I have to add:
binary_sensor:
- platform: flic
- discovery: true
and restart the config.yaml?
Because addind those 3 lines of code gives me a context menu (auto completion menu) with which I don’t know what else to do…
And a small additional question:
As far as I understand one can use the following click-types: click, hold and double… click and hold work just fine… only double does not seem to work.
Maybe someone knows how to resolve that?
I tried this fork but it seems to poll a lot more and create entities that switches between unavailable and available every few seconds. I therefore reverted back to the original ingo fork since I do not use IR anyway.
Still super new to HA and MQTT but trying to set up my Flic to be controlled by a button within HA. I have created a script (yaml below) to try and mimic what I can see when the flic button is clicked. I can see the statuses of the “state” and “action” entities change but the light doesn’t turn on or off at all.
Basically, I’m trying to turn on a light via the flic hub by toggling a button card within HA. Let me know if my use case doesn’t make sense and I can elaborate.
I just used the fork from asosnovsky/flic2hass and it works which is awesome so a big thank you to everyone. The only issue was that I had to create a user and password in the Mosquitto broker config under Settings>Add-ons>Mosquitto Configuration and add that to ./main.js because my Flic Hub was initially getting connection errors.
I can see my Flic buttons in Home Assistant and my automation responds to a Flic button press, however, right away the app on the Flic Hub crashes with stack overflow:
btnc|INFO| is up
ir|INFO| starting...
ir|INFO| is up
root|INFO| all services up!
InternalError: stack overflow
at apply (native)
at emit (core.js:566)
at <anonymous> (root/MQTT/lib.js:933)
at apply (native)
at emit (core.js:566)
at <anonymous> (root/MQTT/lib.js:933)
at apply (native)
...
Here’s the relevant part of lib.js:933
// Get the data for this packet
var pData = data.slice(1 + dLen.lenBy, pLen);
// more than one packet? re-emit it so we handle it later
if (data.length > pLen) {
this.client.emit("data", data.slice(pLen, data.length)); // line 933
}
Perhaps the client object is undefined, but I have not tried to debug the code, but if you’ve seen this or have a fix please share. Thank you.
UPDATE: there is an unmerged pull request in GitHub that someone left for this
> // Get the data for this packet
> var pData = data.slice(1 + dLen.lenBy, pLen);
>
> // Avoid an infinite data emit loop
> if (pData.length < 1) {
> this.partData = data;
> return;
> }
>
> // more than one packet? re-emit it so we handle it later
> if (data.length > pLen) {
> this.client.emit("data", data.slice(pLen, data.length)); // line 933
> }
I too cannot use the new fork - it crashes often and it has the same issue as the original fork which caused me to have to modify the code.
I had to add a sleep function and include it in the code before it flips back to normal from any action.
I have no idea how any of you are using these as-is because the status of the sensors reverts back to normal so quickly that unless I put in that sleep my automations don’t work at all.
The author of this new version also disabled issues. So there is that…