-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,952 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# MQTT broker details | ||
MQTT_HOST="localhost" | ||
MQTT_PORT="1883" | ||
MQTT_TOPIC="homie/switch/switch/state" | ||
|
||
# Function to publish MQTT message | ||
publish_mqtt_message() { | ||
local state="$1" | ||
echo "Publishing state: $state to topic: $MQTT_TOPIC" | ||
mosquitto_pub -h "$MQTT_HOST" -p "$MQTT_PORT" -t "$MQTT_TOPIC" -m "$state" | ||
} | ||
|
||
# Main loop | ||
while true; do | ||
publish_mqtt_message "true" | ||
sleep 2 | ||
publish_mqtt_message "false" | ||
sleep 2 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/// <reference types="node" /> | ||
import { Observable } from 'rxjs'; | ||
interface HomieProperty { | ||
id: string; | ||
value: any; | ||
} | ||
interface HomieNode { | ||
id: string; | ||
properties: { | ||
[key: string]: HomieProperty; | ||
}; | ||
} | ||
interface HomieDevice { | ||
id: string; | ||
nodes: { | ||
[key: string]: HomieNode; | ||
}; | ||
} | ||
declare enum HomieEventType { | ||
Device = "device", | ||
Node = "node", | ||
Property = "property" | ||
} | ||
interface HomieDeviceEvent { | ||
type: HomieEventType.Device; | ||
device: HomieDevice; | ||
} | ||
interface HomieNodeEvent { | ||
type: HomieEventType.Node; | ||
device: HomieDevice; | ||
node: HomieNode; | ||
} | ||
interface HomiePropertyEvent { | ||
type: HomieEventType.Property; | ||
device: HomieDevice; | ||
node: HomieNode; | ||
property: HomieProperty; | ||
} | ||
type HomieEvent = HomieDeviceEvent | HomieNodeEvent | HomiePropertyEvent; | ||
interface MqttMessageHandler { | ||
handleMessage(topic: string, message: Buffer): void; | ||
subscribe(topic: string): void; | ||
} | ||
declare class MqttClient implements MqttMessageHandler { | ||
private client; | ||
private homiePrefix; | ||
private messageCallback; | ||
constructor(brokerUrl: string, options: { | ||
homiePrefix?: string | undefined; | ||
} | undefined, messageCallback: (event: HomieEvent) => void); | ||
subscribe(pattern: string): void; | ||
private getSubscriptionTopic; | ||
handleMessage(topic: string, message: Buffer): void; | ||
private handleDeviceState; | ||
private handleNodeState; | ||
private handlePropertyState; | ||
disconnect(): void; | ||
} | ||
declare class HomieObserver { | ||
private messageHandler; | ||
private devices; | ||
private onCreate; | ||
private onUpdate; | ||
private onDelete; | ||
constructor(messageHandler: MqttMessageHandler); | ||
subscribe(topic: string): void; | ||
get created$(): Observable<HomieEvent>; | ||
get updated$(): Observable<HomieEvent>; | ||
get deleted$(): Observable<HomieEvent>; | ||
processEvent(event: HomieEvent): void; | ||
private processDeviceEvent; | ||
private processNodeEvent; | ||
private processPropertyEvent; | ||
} | ||
declare function createMqttHomieObserver(brokerUrl: string, options?: { | ||
homiePrefix?: string; | ||
}): HomieObserver; | ||
export { HomieObserver, MqttClient, MqttMessageHandler, createMqttHomieObserver, HomieEventType, HomieEvent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Observable } from 'rxjs'; | ||
import { HomieObserver } from './HomieObserver'; | ||
interface BufferedPropertyUpdate { | ||
deviceId: string; | ||
nodeId: string; | ||
propertyId: string; | ||
value: any; | ||
priority: number; | ||
} | ||
interface PropertyGroup { | ||
name: string; | ||
properties: string[]; | ||
priority: number; | ||
} | ||
export declare class HomiePropertyBuffer { | ||
private homieObserver; | ||
private bufferTimeMs; | ||
private propertyUpdates$; | ||
private propertyGroups; | ||
private bufferedUpdates$; | ||
constructor(homieObserver: HomieObserver, bufferTimeMs?: number); | ||
addPropertyGroup(group: PropertyGroup): void; | ||
private getPropertyPriority; | ||
private setupPropertyUpdateStream; | ||
private setupBufferedUpdatesStream; | ||
getBufferedUpdates(): Observable<BufferedPropertyUpdate[]>; | ||
processBufferedUpdates(processor: (updates: BufferedPropertyUpdate[]) => void): void; | ||
} | ||
export {}; |
Oops, something went wrong.