Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2935827f60 | ||
|
|
bf4e69e2ce | ||
|
|
df74989fdd | ||
|
|
969b8bd0e2 | ||
|
|
ec295d3f8a | ||
|
|
c97c9c494c | ||
|
|
ecc223d6e0 |
No files matched your search
@@ -1,12 +1,15 @@
|
|||||||
# Flic2Hass 
|
# Flic2Hass 
|
||||||
|
|
||||||
|
|
||||||
|
> <a href='https://ko-fi.com/J3J8C4RB7' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||||
|
|
||||||
This is a complete refactor of various previous versions of flic2hass. This version provides more features and even supports the onboard IR module!
|
This is a complete refactor of various previous versions of flic2hass. This version provides more features and even supports the onboard IR module!
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Complete Overview of Buttons
|
### Complete Overview of Buttons
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
* Show connectivity state
|
* Show connectivity state
|
||||||
* Show click action types: `click` `hold` `double_click`
|
* Show click action types: `click` `hold` `double_click`
|
||||||
@@ -20,7 +23,7 @@ This is a complete refactor of various previous versions of flic2hass. This vers
|
|||||||
* Record remote signals
|
* Record remote signals
|
||||||
* Send remote signals
|
* Send remote signals
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 164 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 140 KiB |
@@ -705,7 +705,7 @@ Uint8Array.prototype.charCodeAt = function(a, b) {
|
|||||||
this.client = false;
|
this.client = false;
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
/* if keep_alive is less than the ping interval we need to use
|
/* if keep_alive is less than the ping interval we need to use
|
||||||
a shorter ping interval, otherwise we'll just time out! */ this.ping_interval = this.keep_alive < this.C.PING_INTERVAL ? this.keep_alive - 5 : this.C.PING_INTERVAL;
|
a shorter ping interval, otherwise we'll just time out! */ this.ping_interval = this.keep_alive < this.C.PING_INTERVAL ? this.keep_alive - 5 : this.C.PING_INTERVAL;
|
||||||
this.protocol_name = options.protocol_name || "MQTT";
|
this.protocol_name = options.protocol_name || "MQTT";
|
||||||
this.protocol_level = options.protocol_level || C.PROTOCOL_LEVEL;
|
this.protocol_level = options.protocol_level || C.PROTOCOL_LEVEL;
|
||||||
if (typeof this.client_id == "string") {
|
if (typeof this.client_id == "string") {
|
||||||
@@ -926,6 +926,11 @@ MQTT.prototype.packetHandler = function(data) {
|
|||||||
this.partData = data;
|
this.partData = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Allow zero-size pData, but detect if its indexes
|
||||||
|
// will go out of bounds.
|
||||||
|
if (1 + dLen.lenBy >= data.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Get the data for this packet
|
// Get the data for this packet
|
||||||
var pData = data.slice(1 + dLen.lenBy, pLen);
|
var pData = data.slice(1 + dLen.lenBy, pLen);
|
||||||
// more than one packet? re-emit it so we handle it later
|
// more than one packet? re-emit it so we handle it later
|
||||||
@@ -1084,11 +1089,11 @@ MQTT.prototype.packetHandler = function(data) {
|
|||||||
this.client = false;
|
this.client = false;
|
||||||
};
|
};
|
||||||
/** Publish message using specified topic.
|
/** Publish message using specified topic.
|
||||||
opts = {
|
opts = {
|
||||||
retain: bool // the server should retain this message and send it out again to new subscribers
|
retain: bool // the server should retain this message and send it out again to new subscribers
|
||||||
dup : bool // indicate the message is a duplicate because original wasn't ACKed (QoS > 0 only)
|
dup : bool // indicate the message is a duplicate because original wasn't ACKed (QoS > 0 only)
|
||||||
}
|
}
|
||||||
*/ MQTT.prototype.publish = function(topic, message, opts) {
|
*/ MQTT.prototype.publish = function(topic, message, opts) {
|
||||||
if (!this.client) return;
|
if (!this.client) return;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
try {
|
try {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "flic2hass",
|
"name": "flic2hass",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "flic2hass",
|
"name": "flic2hass",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.62",
|
"@swc/cli": "^0.1.62",
|
||||||
|
|||||||
+20
-19
@@ -1,9 +1,10 @@
|
|||||||
import { ButtonControllerOpt, makeButtonController } from "./ButtonController";
|
import {ButtonControllerOpt, makeButtonController} from "./ButtonController";
|
||||||
import { HAmqttOptions, makeHAmqtt } from './HAmqtt';
|
import {HAmqttOptions, makeHAmqtt} from './HAmqtt';
|
||||||
import { IRControllerOpt, makeIRController } from "./IRController";
|
import {IRControllerOpt, makeIRController} from "./IRController";
|
||||||
import { makeLogger } from "./Logger";
|
import {makeLogger} from "./Logger";
|
||||||
import { ButtonModule, IRModule } from './flicTypes';
|
import {ButtonModule, IRModule} from './flicTypes';
|
||||||
import * as mqtt from './mqtt';
|
import * as mqtt from './mqtt';
|
||||||
|
|
||||||
export type MQTTOpt = {
|
export type MQTTOpt = {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
@@ -27,18 +28,18 @@ export const start = (
|
|||||||
) => {
|
) => {
|
||||||
const mqttServer = mqtt.create(
|
const mqttServer = mqtt.create(
|
||||||
options.mqtt.host,
|
options.mqtt.host,
|
||||||
{ ...options.mqtt, keep_alive: true },
|
{...options.mqtt, keep_alive: true},
|
||||||
);
|
);
|
||||||
const logger = makeLogger('root', options.debug ?? false);
|
const logger = makeLogger('root', options.debug ?? false);
|
||||||
options.ha = options.ha ?? {}
|
options.ha = options.ha ?? {};
|
||||||
options.flicBtns = options.flicBtns ?? {}
|
options.flicBtns = options.flicBtns ?? {};
|
||||||
options.flicIR = options.flicIR ?? {}
|
options.flicIR = options.flicIR ?? {};
|
||||||
options.ha.debug = options.ha.debug ?? options.debug ?? false
|
options.ha.debug = options.ha.debug ?? options.debug ?? false;
|
||||||
options.flicBtns.debug = options.flicBtns.debug ?? options.debug ?? false
|
options.flicBtns.debug = options.flicBtns.debug ?? options.debug ?? false;
|
||||||
options.flicIR.debug = options.flicBtns.debug ?? options.debug ?? false
|
options.flicIR.debug = options.flicIR.debug ?? options.debug ?? false;
|
||||||
const ha = makeHAmqtt(mqttServer, options.ha);
|
const ha = makeHAmqtt(mqttServer, options.ha);
|
||||||
mqttServer.on('connected', () => {
|
mqttServer.on('connected', () => {
|
||||||
logger.info("connected to mqtt")
|
logger.info("connected to mqtt");
|
||||||
if (!options.flicBtns?.disabled) {
|
if (!options.flicBtns?.disabled) {
|
||||||
makeButtonController(
|
makeButtonController(
|
||||||
ha, buttonModule, options.flicBtns,
|
ha, buttonModule, options.flicBtns,
|
||||||
@@ -52,25 +53,25 @@ export const start = (
|
|||||||
options.flicIR,
|
options.flicIR,
|
||||||
).start();
|
).start();
|
||||||
}
|
}
|
||||||
logger.info("all services up!")
|
logger.info("all services up!");
|
||||||
});
|
});
|
||||||
mqttServer.on('error', function (err) {
|
mqttServer.on('error', function (err) {
|
||||||
logger.info("'Error' event", JSON.stringify(err));
|
logger.info("'Error' event", JSON.stringify(err));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
throw new Error("Crashed")
|
throw new Error("Crashed");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
mqttServer.on("disconnected", function (err) {
|
mqttServer.on("disconnected", function (err) {
|
||||||
logger.info("'Error' disconnected", JSON.stringify(err));
|
logger.info("'Error' disconnected", JSON.stringify(err));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
throw new Error("Crashed")
|
throw new Error("Crashed");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
mqttServer.on("close", function (err) {
|
mqttServer.on("close", function (err) {
|
||||||
logger.info("'Error' close", JSON.stringify(err));
|
logger.info("'Error' close", JSON.stringify(err));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
throw new Error("Crashed")
|
throw new Error("Crashed");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
mqttServer.connect()
|
mqttServer.connect();
|
||||||
}
|
};
|
||||||
+441
-417
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user