homebridge-tasmota 0.2.2 → 0.2.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npm-version-script-esm.js +97 -0
- package/CHANGELOG.md +8 -0
- package/DEVICES.md +47 -39
- package/dist/tasmotaSwitchService.js +13 -12
- package/dist/tasmotaSwitchService.js.map +1 -1
- package/gh-md-toc +421 -0
- package/package.json +2 -2
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import assert from 'node:assert'
|
|
8
|
+
import child_process from 'node:child_process'
|
|
9
|
+
import fs from 'node:fs'
|
|
10
|
+
import process from 'node:process'
|
|
11
|
+
|
|
12
|
+
const BRANCH_VERSION_PATTERN = /^([A-Z]+)-(\d+\.\d+\.\d+)$/i
|
|
13
|
+
|
|
14
|
+
// Load the contents of the package.json file
|
|
15
|
+
const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
|
16
|
+
|
|
17
|
+
const refArgument = process.argv[2]
|
|
18
|
+
const tagArgument = process.argv[3] || 'latest'
|
|
19
|
+
|
|
20
|
+
if (!refArgument) {
|
|
21
|
+
console.error('ref argument is missing')
|
|
22
|
+
console.error('Usage: npm-version-script-esm.js <ref> [tag]')
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Queries the NPM registry for the latest version for the provided base version and tag.
|
|
28
|
+
* If the tag is latest, then the base version is returned if it exists. For other tags, the latest
|
|
29
|
+
* version found for that base version and tag is returned.
|
|
30
|
+
* @param baseVersion The base version to query for, e.g. 2.0.0
|
|
31
|
+
* @param tag The tag to query for, e.g. beta or latest
|
|
32
|
+
* @returns {string} Returns the version, or '' if not found
|
|
33
|
+
*/
|
|
34
|
+
function getTagVersionFromNpm(baseVersion, tag) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(child_process.execSync(`npm info ${packageJSON.name} versions --json`).toString('utf8').trim())
|
|
37
|
+
.filter(v => tag === 'latest' ? v === baseVersion : v.startsWith(`${baseVersion}-${tag}.`)) // find all published versions for this base version and tag
|
|
38
|
+
.reduce((_, current) => current, '') // choose the last as they're sorted in ascending order, or '' if there are none
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`, e)
|
|
41
|
+
// throw e;
|
|
42
|
+
return ''
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function desiredTargetVersion(ref) {
|
|
47
|
+
// ref is a GitHub action ref string
|
|
48
|
+
if (ref.startsWith('refs/pull/')) {
|
|
49
|
+
throw new Error('The version script was executed inside a PR!')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
assert(ref.startsWith('refs/heads/'))
|
|
53
|
+
const branchName = ref.slice('refs/heads/'.length)
|
|
54
|
+
|
|
55
|
+
const results = branchName.match(BRANCH_VERSION_PATTERN)
|
|
56
|
+
if (results !== null) {
|
|
57
|
+
if (results[1] !== tagArgument) {
|
|
58
|
+
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return results[2]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
throw new Error(`Malformed branch name for ref: ${ref}. Can't derive the base version. Use a branch name like: beta-x.x.x or alpha-x.x.x`)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// derive the base version from the branch ref
|
|
68
|
+
const baseVersion = desiredTargetVersion(refArgument)
|
|
69
|
+
|
|
70
|
+
// query the npm registry for the latest version of the provided tag name
|
|
71
|
+
const latestReleasedVersion = getTagVersionFromNpm(baseVersion, tagArgument) // e.g. 0.7.0-beta.12
|
|
72
|
+
|
|
73
|
+
let publishTag
|
|
74
|
+
|
|
75
|
+
if (latestReleasedVersion) {
|
|
76
|
+
console.warn(`Latest published version for ${baseVersion} with tag ${tagArgument} is ${latestReleasedVersion}`)
|
|
77
|
+
publishTag = latestReleasedVersion // set this released beta or alpha to be incremented
|
|
78
|
+
} else {
|
|
79
|
+
console.warn(`No published versions for ${baseVersion} with tag ${tagArgument}`)
|
|
80
|
+
publishTag = baseVersion // start off with a new beta or alpha version
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (packageJSON.version !== publishTag) {
|
|
84
|
+
// report the change for CI
|
|
85
|
+
console.warn(`Changing version in package.json from ${packageJSON.version} to ${publishTag}`)
|
|
86
|
+
|
|
87
|
+
// save the package.json
|
|
88
|
+
packageJSON.version = publishTag
|
|
89
|
+
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2))
|
|
90
|
+
|
|
91
|
+
// perform the same change to the package-lock.json
|
|
92
|
+
const packageLockJSON = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'))
|
|
93
|
+
packageLockJSON.version = publishTag
|
|
94
|
+
fs.writeFileSync('package-lock.json', JSON.stringify(packageLockJSON, null, 2))
|
|
95
|
+
} else {
|
|
96
|
+
console.warn(`Leaving version in package.json at ${packageJSON.version}`)
|
|
97
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## 0.2.3 (2025-04-15)
|
|
6
|
+
|
|
7
|
+
## [Version 0.2.3](https://github.com/northernman54/homebridge-tasmota/compare/0.2.3...0.2.3)
|
|
8
|
+
|
|
9
|
+
#### Changes
|
|
10
|
+
|
|
11
|
+
- Fix for power bars with multiple relays and not all relays appearing
|
|
12
|
+
|
|
5
13
|
## 0.2.2 (2024-12-23)
|
|
6
14
|
|
|
7
15
|
## [Version 0.2.2](https://github.com/northernman54/homebridge-tasmota/compare/0.2.1...0.2.2)
|
package/DEVICES.md
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
<H1>Sample Device Configurations ( My personal collection )</H1>
|
|
2
2
|
|
|
3
3
|
<!--ts-->
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* [Version 2](#version-2)
|
|
42
|
-
* [Version 3 - Do three checks before rebooting](#version-3---do-three-checks-before-rebooting)
|
|
4
|
+
- [Sonoff IFAN03](#sonoff-ifan03)
|
|
5
|
+
- [Tasmota Configuration](#tasmota-configuration-1)
|
|
6
|
+
- [configuration override of discovery object to create a FAN ( post version 0.1.0 )](#configuration-override-of-discovery-object-to-create-a-fan--post-version-010-)
|
|
7
|
+
- [configuration override of discovery object to create a FAN ( pre version 0.1.0 )](#configuration-override-of-discovery-object-to-create-a-fan--pre-version-010-)
|
|
8
|
+
- [Slave a FEIT Wifi Dimmer Wall Switch to an iFan as a light switch](#slave-a-feit-wifi-dimmer-wall-switch-to-an-ifan-as-a-light-switch)
|
|
9
|
+
- [BME280 Temperature Sensor - MCUIOT](#bme280-temperature-sensor---mcuiot)
|
|
10
|
+
- [DHT11 Temperature Sensor - MCUIOT](#dht11-temperature-sensor---mcuiot)
|
|
11
|
+
- [Water Leak Sensor with On/Off control](#water-leak-sensor-with-onoff-control)
|
|
12
|
+
- [LEAK Tasmota configuration - DHT11](#leak-tasmota-configuration---dht11)
|
|
13
|
+
- [Leak Tasmota configuration - BME280](#leak-tasmota-configuration---bme280)
|
|
14
|
+
- [Motion + BME280 Temperature Sensor](#motion--bme280-temperature-sensor)
|
|
15
|
+
- [PIR Motion + BME280 Temperature Sensor + BH1750 Lux Illuminance Sensor](#pir-motion--bme280-temperature-sensor--bh1750-lux-illuminance-sensor)
|
|
16
|
+
- [ZMAi-90 Current Sensor Switch](#zmai-90-current-sensor-switch)
|
|
17
|
+
- [MCULED Device with RGB+W Strip](#mculed-device-with-rgbw-strip)
|
|
18
|
+
- [MCULED Device with RGB+W Strip - Version 2 ( Basement )](#mculed-device-with-rgbw-strip---version-2--basement-)
|
|
19
|
+
- [MCULED Device with RGB+W Strip - Version 2 ( Cottage Sink )](#mculed-device-with-rgbw-strip---version-2--cottage-sink-)
|
|
20
|
+
- [Tuya Dimmer Module as a FAN](#tuya-dimmer-module-as-a-fan)
|
|
21
|
+
- [Trailer Relay Board](#trailer-relay-board)
|
|
22
|
+
- [Gowfeel EN71 Water Valve](#gowfeel-en71-water-valve)
|
|
23
|
+
- [Homebrew Doorbutton Button](#homebrew-doorbutton-button)
|
|
24
|
+
- [Homebrew Garage Door Opener](#homebrew-garage-door-opener)
|
|
25
|
+
- [CE SMART Wifi Dimmer](#ce-smart-wifi-dimmer)
|
|
26
|
+
- [FEIT Wifi Dimmer](#feit-wifi-dimmer)
|
|
27
|
+
- [Using a FEIT Wifi Dimmer as a remote switch to OpenBK RGBCCT Potlights](#using-a-feit-wifi-dimmer-as-a-remote-switch-to-openbk-rgbcct-potlights)
|
|
28
|
+
- [Turn off after 30 minutes](#turn-off-after-30-minutes)
|
|
29
|
+
- [Hampton Bay Fan/Light RF Remote Control ( 303.9 Mhz )](#hampton-bay-fanlight-rf-remote-control--3039-mhz-)
|
|
30
|
+
- [Valor Fireplace Remote ( 315 Mhz )](#valor-fireplace-remote--315-mhz-)
|
|
31
|
+
- [Treatlife DS03 Fan Controller and Light Dimmer](#treatlife-ds03-fan-controller-and-light-dimmer)
|
|
32
|
+
- [Greeni GNC-SW003-199](#greeni-gnc-sw003-199)
|
|
33
|
+
- [OpenMQTTGateway devices](#openmqttgateway-devices)
|
|
34
|
+
- [Hampton Bay Light](#hampton-bay-light)
|
|
35
|
+
- [Hampton Bay FAN](#hampton-bay-fan)
|
|
36
|
+
- [openMQTTGateway / PiLight temperature sensor](#openmqttgateway--pilight-temperature-sensor)
|
|
37
|
+
- [Internet Connection WatchDog](#internet-connection-watchdog)
|
|
38
|
+
- [Version 1 ( Uses node-red to monitor google.com and turn off the plug )](#version-1--uses-node-red-to-monitor-googlecom-and-turn-off-the-plug-)
|
|
39
|
+
- [Version 2](#version-2)
|
|
40
|
+
- [Version 3 - Do three checks before rebooting](#version-3---do-three-checks-before-rebooting)
|
|
43
41
|
<!--te-->
|
|
44
42
|
|
|
45
43
|
# My standard config after setting name and device configuration <!-- omit in toc -->
|
|
@@ -596,6 +594,16 @@ tuyamcu 62,3 --> 62 for 4 speeds fan controller (possible values 0,1,2,3)
|
|
|
596
594
|
}
|
|
597
595
|
```
|
|
598
596
|
|
|
597
|
+
# Greeni GNC-SW003-199
|
|
598
|
+
|
|
599
|
+
* Tasmota configuration
|
|
600
|
+
|
|
601
|
+
```
|
|
602
|
+
backlog template {"NAME":"Geeni GNC-SW003-199","GPIO":[320,0,0,32,226,225,0,0,228,229,227,224,0,0],"FLAG":0,"BASE":18}; module 0
|
|
603
|
+
backlog Friendlyname1 Switch 1; Friendlyname2 Switch 2; Friendlyname3 Switch 3; Friendlyname4 Switch 4; Friendlyname5 Switch 5; Friendlyname6 Switch 6
|
|
604
|
+
Backlog MqttHost mqtt.local; topic tasmota_%06X; setoption57 1; setoption19 1
|
|
605
|
+
```
|
|
606
|
+
|
|
599
607
|
# OpenMQTTGateway devices
|
|
600
608
|
|
|
601
609
|
I have been working on utilizing an OpenMQTTGateway device configured with a cc1101 RF Transceiver and the GatewayRF module. The goal is to control my Hampton Bay ( 303 Mhz ), and GE Fans ( 315 Mhz ) and other RF devices.
|
|
@@ -15,20 +15,21 @@ export class tasmotaSwitchService extends TasmotaService {
|
|
|
15
15
|
this.platform = platform;
|
|
16
16
|
this.accessory = accessory;
|
|
17
17
|
this.uniq_id = uniq_id;
|
|
18
|
+
/*
|
|
18
19
|
if (this.accessory.getService(this.uuid)) {
|
|
19
|
-
|
|
20
|
+
this.service = this.accessory.getService(this.uuid)!;
|
|
21
|
+
} else if (this.accessory.getService(this.platform.Service.Outlet)) {
|
|
22
|
+
const temp = this.accessory.getService(this.platform.Service.Outlet)!;
|
|
23
|
+
if (temp.name === null) {
|
|
24
|
+
this.service = temp!;
|
|
25
|
+
this.service.name = accessory.context.device[this.uniq_id].name;
|
|
26
|
+
this.service.displayName = accessory.context.device[this.uniq_id].name;
|
|
27
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.context.device[this.uniq_id].name)!;
|
|
28
|
+
this.service.subtype = this.uuid;
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (temp.name === null) {
|
|
24
|
-
this.service = temp;
|
|
25
|
-
this.service.name = accessory.context.device[this.uniq_id].name;
|
|
26
|
-
this.service.displayName = accessory.context.device[this.uniq_id].name;
|
|
27
|
-
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.context.device[this.uniq_id].name);
|
|
28
|
-
this.service.subtype = this.uuid;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
this.service = this.service || this.accessory.addService(this.platform.Service.Outlet, accessory.context.device[this.uniq_id].name, this.uuid);
|
|
31
|
+
*/
|
|
32
|
+
this.service = this.accessory.getService(this.uuid) || this.accessory.addService(this.platform.Service.Outlet, accessory.context.device[this.uniq_id].name, this.uuid);
|
|
32
33
|
this.service?.setCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.context.device[this.uniq_id].name);
|
|
33
34
|
this.service?.setPrimaryService(true);
|
|
34
35
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasmotaSwitchService.js","sourceRoot":"","sources":["../src/tasmotaSwitchService.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7D,MAAM,KAAK,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAE5C;;;;GAIG;AAEH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAEpC;IACA;IACG;IAHrB,YACkB,QAAyB,EACzB,SAA4B,EACzB,OAAe;QAElC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAJpB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QACzB,YAAO,GAAP,OAAO,CAAQ;QAIlC
|
|
1
|
+
{"version":3,"file":"tasmotaSwitchService.js","sourceRoot":"","sources":["../src/tasmotaSwitchService.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7D,MAAM,KAAK,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAE5C;;;;GAIG;AAEH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAEpC;IACA;IACG;IAHrB,YACkB,QAAyB,EACzB,SAA4B,EACzB,OAAe;QAElC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAJpB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QACzB,YAAO,GAAP,OAAO,CAAQ;QAIlC;;;;;;;;;;;;;UAaE;QAEF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,UAA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AAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxB,CAAC,CAAC;gBACH,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC;oBAChD,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxB,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,6DAA6D;YAC/D,CAAC;QACH,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAK,GAAa,CAAC,OAAO,CAAC,CAAC,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACpG,CAAC;QACD,sCAAsC;QACtC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCE;AACF;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;GAeG"}
|
package/gh-md-toc
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Steps:
|
|
5
|
+
#
|
|
6
|
+
# 1. Download corresponding html file for some README.md:
|
|
7
|
+
# curl -s $1
|
|
8
|
+
#
|
|
9
|
+
# 2. Discard rows where no substring 'user-content-' (github's markup):
|
|
10
|
+
# awk '/user-content-/ { ...
|
|
11
|
+
#
|
|
12
|
+
# 3.1 Get last number in each row like ' ... </span></a>sitemap.js</h1'.
|
|
13
|
+
# It's a level of the current header:
|
|
14
|
+
# substr($0, length($0), 1)
|
|
15
|
+
#
|
|
16
|
+
# 3.2 Get level from 3.1 and insert corresponding number of spaces before '*':
|
|
17
|
+
# sprintf("%*s", (level-1)*'"$nb_spaces"', "")
|
|
18
|
+
#
|
|
19
|
+
# 4. Find head's text and insert it inside "* [ ... ]":
|
|
20
|
+
# substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
|
|
21
|
+
#
|
|
22
|
+
# 5. Find anchor and insert it inside "(...)":
|
|
23
|
+
# substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8)
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
gh_toc_version="0.10.0"
|
|
27
|
+
|
|
28
|
+
gh_user_agent="gh-md-toc v$gh_toc_version"
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Download rendered into html README.md by its url.
|
|
32
|
+
#
|
|
33
|
+
#
|
|
34
|
+
gh_toc_load() {
|
|
35
|
+
local gh_url=$1
|
|
36
|
+
|
|
37
|
+
if type curl &>/dev/null; then
|
|
38
|
+
curl --user-agent "$gh_user_agent" -s "$gh_url"
|
|
39
|
+
elif type wget &>/dev/null; then
|
|
40
|
+
wget --user-agent="$gh_user_agent" -qO- "$gh_url"
|
|
41
|
+
else
|
|
42
|
+
echo "Please, install 'curl' or 'wget' and try again."
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Converts local md file into html by GitHub
|
|
49
|
+
#
|
|
50
|
+
# -> curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown
|
|
51
|
+
# <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'"
|
|
52
|
+
gh_toc_md2html() {
|
|
53
|
+
local gh_file_md=$1
|
|
54
|
+
local skip_header=$2
|
|
55
|
+
|
|
56
|
+
URL=https://api.github.com/markdown/raw
|
|
57
|
+
|
|
58
|
+
if [ -n "$GH_TOC_TOKEN" ]; then
|
|
59
|
+
TOKEN=$GH_TOC_TOKEN
|
|
60
|
+
else
|
|
61
|
+
TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
|
|
62
|
+
if [ -f "$TOKEN_FILE" ]; then
|
|
63
|
+
TOKEN="$(cat "$TOKEN_FILE")"
|
|
64
|
+
fi
|
|
65
|
+
fi
|
|
66
|
+
if [ -n "${TOKEN}" ]; then
|
|
67
|
+
AUTHORIZATION="Authorization: token ${TOKEN}"
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
local gh_tmp_file_md=$gh_file_md
|
|
71
|
+
if [ "$skip_header" = "yes" ]; then
|
|
72
|
+
if grep -Fxq "<!--te-->" "$gh_src"; then
|
|
73
|
+
# cut everything before the toc
|
|
74
|
+
gh_tmp_file_md=$gh_file_md~~
|
|
75
|
+
sed '1,/<!--te-->/d' "$gh_file_md" > "$gh_tmp_file_md"
|
|
76
|
+
fi
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# echo $URL 1>&2
|
|
80
|
+
OUTPUT=$(curl -s \
|
|
81
|
+
--user-agent "$gh_user_agent" \
|
|
82
|
+
--data-binary @"$gh_tmp_file_md" \
|
|
83
|
+
-H "Content-Type:text/plain" \
|
|
84
|
+
-H "$AUTHORIZATION" \
|
|
85
|
+
"$URL")
|
|
86
|
+
|
|
87
|
+
rm -f "${gh_file_md}~~"
|
|
88
|
+
|
|
89
|
+
if [ "$?" != "0" ]; then
|
|
90
|
+
echo "XXNetworkErrorXX"
|
|
91
|
+
fi
|
|
92
|
+
if [ "$(echo "${OUTPUT}" | awk '/API rate limit exceeded/')" != "" ]; then
|
|
93
|
+
echo "XXRateLimitXX"
|
|
94
|
+
else
|
|
95
|
+
echo "${OUTPUT}"
|
|
96
|
+
fi
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
#
|
|
101
|
+
# Is passed string url
|
|
102
|
+
#
|
|
103
|
+
gh_is_url() {
|
|
104
|
+
case $1 in
|
|
105
|
+
https* | http*)
|
|
106
|
+
echo "yes";;
|
|
107
|
+
*)
|
|
108
|
+
echo "no";;
|
|
109
|
+
esac
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#
|
|
113
|
+
# TOC generator
|
|
114
|
+
#
|
|
115
|
+
gh_toc(){
|
|
116
|
+
local gh_src=$1
|
|
117
|
+
local gh_src_copy=$1
|
|
118
|
+
local gh_ttl_docs=$2
|
|
119
|
+
local need_replace=$3
|
|
120
|
+
local no_backup=$4
|
|
121
|
+
local no_footer=$5
|
|
122
|
+
local indent=$6
|
|
123
|
+
local skip_header=$7
|
|
124
|
+
|
|
125
|
+
if [ "$gh_src" = "" ]; then
|
|
126
|
+
echo "Please, enter URL or local path for a README.md"
|
|
127
|
+
exit 1
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Show "TOC" string only if working with one document
|
|
132
|
+
if [ "$gh_ttl_docs" = "1" ]; then
|
|
133
|
+
|
|
134
|
+
echo "Table of Contents"
|
|
135
|
+
echo "================="
|
|
136
|
+
echo ""
|
|
137
|
+
gh_src_copy=""
|
|
138
|
+
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
if [ "$(gh_is_url "$gh_src")" == "yes" ]; then
|
|
142
|
+
gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" "$indent"
|
|
143
|
+
if [ "${PIPESTATUS[0]}" != "0" ]; then
|
|
144
|
+
echo "Could not load remote document."
|
|
145
|
+
echo "Please check your url or network connectivity"
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
if [ "$need_replace" = "yes" ]; then
|
|
149
|
+
echo
|
|
150
|
+
echo "!! '$gh_src' is not a local file"
|
|
151
|
+
echo "!! Can't insert the TOC into it."
|
|
152
|
+
echo
|
|
153
|
+
fi
|
|
154
|
+
else
|
|
155
|
+
local rawhtml
|
|
156
|
+
rawhtml=$(gh_toc_md2html "$gh_src" "$skip_header")
|
|
157
|
+
if [ "$rawhtml" == "XXNetworkErrorXX" ]; then
|
|
158
|
+
echo "Parsing local markdown file requires access to github API"
|
|
159
|
+
echo "Please make sure curl is installed and check your network connectivity"
|
|
160
|
+
exit 1
|
|
161
|
+
fi
|
|
162
|
+
if [ "$rawhtml" == "XXRateLimitXX" ]; then
|
|
163
|
+
echo "Parsing local markdown file requires access to github API"
|
|
164
|
+
echo "Error: You exceeded the hourly limit. See: https://developer.github.com/v3/#rate-limiting"
|
|
165
|
+
TOKEN_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
|
|
166
|
+
echo "or place GitHub auth token here: ${TOKEN_FILE}"
|
|
167
|
+
exit 1
|
|
168
|
+
fi
|
|
169
|
+
local toc
|
|
170
|
+
toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent"`
|
|
171
|
+
echo "$toc"
|
|
172
|
+
if [ "$need_replace" = "yes" ]; then
|
|
173
|
+
if grep -Fxq "<!--ts-->" "$gh_src" && grep -Fxq "<!--te-->" "$gh_src"; then
|
|
174
|
+
echo "Found markers"
|
|
175
|
+
else
|
|
176
|
+
echo "You don't have <!--ts--> or <!--te--> in your file...exiting"
|
|
177
|
+
exit 1
|
|
178
|
+
fi
|
|
179
|
+
local ts="<\!--ts-->"
|
|
180
|
+
local te="<\!--te-->"
|
|
181
|
+
local dt
|
|
182
|
+
dt=$(date +'%F_%H%M%S')
|
|
183
|
+
local ext=".orig.${dt}"
|
|
184
|
+
local toc_path="${gh_src}.toc.${dt}"
|
|
185
|
+
local toc_createdby="<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
|
|
186
|
+
local toc_footer
|
|
187
|
+
toc_footer="<!-- Added by: `whoami`, at: `date` -->"
|
|
188
|
+
# http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
|
|
189
|
+
# clear old TOC
|
|
190
|
+
sed -i"${ext}" "/${ts}/,/${te}/{//!d;}" "$gh_src"
|
|
191
|
+
# create toc file
|
|
192
|
+
echo "${toc}" > "${toc_path}"
|
|
193
|
+
if [ "${no_footer}" != "yes" ]; then
|
|
194
|
+
echo -e "\n${toc_createdby}\n${toc_footer}\n" >> "$toc_path"
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
# insert toc file
|
|
198
|
+
if ! sed --version > /dev/null 2>&1; then
|
|
199
|
+
sed -i "" "/${ts}/r ${toc_path}" "$gh_src"
|
|
200
|
+
else
|
|
201
|
+
sed -i "/${ts}/r ${toc_path}" "$gh_src"
|
|
202
|
+
fi
|
|
203
|
+
echo
|
|
204
|
+
if [ "${no_backup}" = "yes" ]; then
|
|
205
|
+
rm "$toc_path" "$gh_src$ext"
|
|
206
|
+
fi
|
|
207
|
+
echo "!! TOC was added into: '$gh_src'"
|
|
208
|
+
if [ -z "${no_backup}" ]; then
|
|
209
|
+
echo "!! Origin version of the file: '${gh_src}${ext}'"
|
|
210
|
+
echo "!! TOC added into a separate file: '${toc_path}'"
|
|
211
|
+
fi
|
|
212
|
+
echo
|
|
213
|
+
fi
|
|
214
|
+
fi
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
#
|
|
218
|
+
# Grabber of the TOC from rendered html
|
|
219
|
+
#
|
|
220
|
+
# $1 - a source url of document.
|
|
221
|
+
# It's need if TOC is generated for multiple documents.
|
|
222
|
+
# $2 - number of spaces used to indent.
|
|
223
|
+
#
|
|
224
|
+
gh_toc_grab() {
|
|
225
|
+
|
|
226
|
+
href_regex="/href=\"[^\"]+?\"/"
|
|
227
|
+
common_awk_script='
|
|
228
|
+
modified_href = ""
|
|
229
|
+
split(href, chars, "")
|
|
230
|
+
for (i=1;i <= length(href); i++) {
|
|
231
|
+
c = chars[i]
|
|
232
|
+
res = ""
|
|
233
|
+
if (c == "+") {
|
|
234
|
+
res = " "
|
|
235
|
+
} else {
|
|
236
|
+
if (c == "%") {
|
|
237
|
+
res = "\\x"
|
|
238
|
+
} else {
|
|
239
|
+
res = c ""
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
modified_href = modified_href res
|
|
243
|
+
}
|
|
244
|
+
print sprintf("%*s", (level-1)*'"$2"', "") "* [" text "](" gh_url modified_href ")"
|
|
245
|
+
'
|
|
246
|
+
if [ "`uname -s`" == "OS/390" ]; then
|
|
247
|
+
grepcmd="pcregrep -o"
|
|
248
|
+
echoargs=""
|
|
249
|
+
awkscript='{
|
|
250
|
+
level = substr($0, 3, 1)
|
|
251
|
+
text = substr($0, match($0, /<\/span><\/a>[^<]*<\/h/)+11, RLENGTH-14)
|
|
252
|
+
href = substr($0, match($0, '$href_regex')+6, RLENGTH-7)
|
|
253
|
+
'"$common_awk_script"'
|
|
254
|
+
}'
|
|
255
|
+
else
|
|
256
|
+
grepcmd="grep -Eo"
|
|
257
|
+
echoargs="-e"
|
|
258
|
+
awkscript='{
|
|
259
|
+
level = substr($0, 3, 1)
|
|
260
|
+
text = substr($0, match($0, /">.*<\/h/)+2, RLENGTH-5)
|
|
261
|
+
href = substr($0, match($0, '$href_regex')+6, RLENGTH-7)
|
|
262
|
+
'"$common_awk_script"'
|
|
263
|
+
}'
|
|
264
|
+
fi
|
|
265
|
+
|
|
266
|
+
# if closed <h[1-6]> is on the new line, then move it on the prev line
|
|
267
|
+
# for example:
|
|
268
|
+
# was: The command <code>foo1</code>
|
|
269
|
+
# </h1>
|
|
270
|
+
# became: The command <code>foo1</code></h1>
|
|
271
|
+
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |
|
|
272
|
+
|
|
273
|
+
# Sometimes a line can start with <span>. Fix that.
|
|
274
|
+
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<span/<span/g' |
|
|
275
|
+
|
|
276
|
+
# find strings that corresponds to template
|
|
277
|
+
$grepcmd '<h.*class="heading-element".*</a' |
|
|
278
|
+
|
|
279
|
+
# remove code tags
|
|
280
|
+
sed 's/<code>//g' | sed 's/<\/code>//g' |
|
|
281
|
+
|
|
282
|
+
# remove g-emoji
|
|
283
|
+
sed 's/<g-emoji[^>]*[^<]*<\/g-emoji> //g' |
|
|
284
|
+
|
|
285
|
+
# now all rows are like:
|
|
286
|
+
# <h1 class="heading-element">title</h1><a href="..."><span>..</span></a>
|
|
287
|
+
# format result line
|
|
288
|
+
# * $0 - whole string
|
|
289
|
+
# * last element of each row: "</hN" where N in (1,2,3,...)
|
|
290
|
+
echo $echoargs "$(awk -v "gh_url=$1" "$awkscript")"
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
# perl -lpE 's/(\[[^\]]*\]\()(.*?)(\))/my ($pre, $in, $post)=($1, $2, $3) ; $in =~ s{\+}{ }g; $in =~ s{%}{\\x}g; $pre.$in.$post/ems')"
|
|
294
|
+
|
|
295
|
+
#
|
|
296
|
+
# Returns filename only from full path or url
|
|
297
|
+
#
|
|
298
|
+
gh_toc_get_filename() {
|
|
299
|
+
echo "${1##*/}"
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
show_version() {
|
|
303
|
+
echo "$gh_toc_version"
|
|
304
|
+
echo
|
|
305
|
+
echo "os: `uname -s`"
|
|
306
|
+
echo "arch: `uname -m`"
|
|
307
|
+
echo "kernel: `uname -r`"
|
|
308
|
+
echo "shell: `$SHELL --version`"
|
|
309
|
+
echo
|
|
310
|
+
for tool in curl wget grep awk sed; do
|
|
311
|
+
printf "%-5s: " $tool
|
|
312
|
+
if type $tool &>/dev/null; then
|
|
313
|
+
$tool --version | head -n 1
|
|
314
|
+
else
|
|
315
|
+
echo "not installed"
|
|
316
|
+
fi
|
|
317
|
+
done
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
show_help() {
|
|
321
|
+
local app_name
|
|
322
|
+
app_name=$(basename "$0")
|
|
323
|
+
echo "GitHub TOC generator ($app_name): $gh_toc_version"
|
|
324
|
+
echo ""
|
|
325
|
+
echo "Usage:"
|
|
326
|
+
echo " $app_name [options] src [src] Create TOC for a README file (url or local path)"
|
|
327
|
+
echo " $app_name - Create TOC for markdown from STDIN"
|
|
328
|
+
echo " $app_name --help Show help"
|
|
329
|
+
echo " $app_name --version Show version"
|
|
330
|
+
echo ""
|
|
331
|
+
echo "Options:"
|
|
332
|
+
echo " --indent <NUM> Set indent size. Default: 3."
|
|
333
|
+
echo " --insert Insert new TOC into original file. For local files only. Default: false."
|
|
334
|
+
echo " See https://github.com/ekalinin/github-markdown-toc/issues/41 for details."
|
|
335
|
+
echo " --no-backup Remove backup file. Set --insert as well. Default: false."
|
|
336
|
+
echo " --hide-footer Do not write date & author of the last TOC update. Set --insert as well. Default: false."
|
|
337
|
+
echo " --skip-header Hide entry of the topmost headlines. Default: false."
|
|
338
|
+
echo " See https://github.com/ekalinin/github-markdown-toc/issues/125 for details."
|
|
339
|
+
echo ""
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
#
|
|
343
|
+
# Options handlers
|
|
344
|
+
#
|
|
345
|
+
gh_toc_app() {
|
|
346
|
+
local need_replace="no"
|
|
347
|
+
local indent=3
|
|
348
|
+
|
|
349
|
+
if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then
|
|
350
|
+
show_help
|
|
351
|
+
return
|
|
352
|
+
fi
|
|
353
|
+
|
|
354
|
+
if [ "$1" = '--version' ]; then
|
|
355
|
+
show_version
|
|
356
|
+
return
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
if [ "$1" = '--indent' ]; then
|
|
360
|
+
indent="$2"
|
|
361
|
+
shift 2
|
|
362
|
+
fi
|
|
363
|
+
|
|
364
|
+
if [ "$1" = "-" ]; then
|
|
365
|
+
if [ -z "$TMPDIR" ]; then
|
|
366
|
+
TMPDIR="/tmp"
|
|
367
|
+
elif [ -n "$TMPDIR" ] && [ ! -d "$TMPDIR" ]; then
|
|
368
|
+
mkdir -p "$TMPDIR"
|
|
369
|
+
fi
|
|
370
|
+
local gh_tmp_md
|
|
371
|
+
if [ "`uname -s`" == "OS/390" ]; then
|
|
372
|
+
local timestamp
|
|
373
|
+
timestamp=$(date +%m%d%Y%H%M%S)
|
|
374
|
+
gh_tmp_md="$TMPDIR/tmp.$timestamp"
|
|
375
|
+
else
|
|
376
|
+
gh_tmp_md=$(mktemp "$TMPDIR/tmp.XXXXXX")
|
|
377
|
+
fi
|
|
378
|
+
while read -r input; do
|
|
379
|
+
echo "$input" >> "$gh_tmp_md"
|
|
380
|
+
done
|
|
381
|
+
gh_toc_md2html "$gh_tmp_md" | gh_toc_grab "" "$indent"
|
|
382
|
+
return
|
|
383
|
+
fi
|
|
384
|
+
|
|
385
|
+
if [ "$1" = '--insert' ]; then
|
|
386
|
+
need_replace="yes"
|
|
387
|
+
shift
|
|
388
|
+
fi
|
|
389
|
+
|
|
390
|
+
if [ "$1" = '--no-backup' ]; then
|
|
391
|
+
need_replace="yes"
|
|
392
|
+
no_backup="yes"
|
|
393
|
+
shift
|
|
394
|
+
fi
|
|
395
|
+
|
|
396
|
+
if [ "$1" = '--hide-footer' ]; then
|
|
397
|
+
need_replace="yes"
|
|
398
|
+
no_footer="yes"
|
|
399
|
+
shift
|
|
400
|
+
fi
|
|
401
|
+
|
|
402
|
+
if [ "$1" = '--skip-header' ]; then
|
|
403
|
+
skip_header="yes"
|
|
404
|
+
shift
|
|
405
|
+
fi
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
for md in "$@"
|
|
409
|
+
do
|
|
410
|
+
echo ""
|
|
411
|
+
gh_toc "$md" "$#" "$need_replace" "$no_backup" "$no_footer" "$indent" "$skip_header"
|
|
412
|
+
done
|
|
413
|
+
|
|
414
|
+
echo ""
|
|
415
|
+
echo "<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
#
|
|
419
|
+
# Entry point
|
|
420
|
+
#
|
|
421
|
+
gh_toc_app "$@"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Tasmota",
|
|
3
3
|
"name": "homebridge-tasmota",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3-beta.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Homebridge plugin for Tasmota devices leveraging home assistant auto discovery.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -72,4 +72,4 @@
|
|
|
72
72
|
"typescript-eslint": "^8.12.2"
|
|
73
73
|
},
|
|
74
74
|
"homepage": "https://github.com/NorthernMan54/homebridge-tasmota#readme"
|
|
75
|
-
}
|
|
75
|
+
}
|