Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Oct 4, 2024
1 parent c224b75 commit dacdde9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
20 changes: 18 additions & 2 deletions ledder/animations/MQTT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class MQTT extends Animator {

this.box = box

const mqttHost = controls.input('MQTT host', "mqtt", true)
const mqttHost = controls.input('MQTT host', "localhost", true)
const mqttTopic = controls.input('MQTT topic', "ledder", true)

let childControls = controls.group('Current animation')
Expand All @@ -54,10 +54,26 @@ export default class MQTT extends Animator {

this.animationManager = new AnimationManager(box, scheduler.child(), childControls)

this.statusMessage(`Conn ${mqttHost.text}...`)
this.statusMessage(`conn ${mqttHost.text}`)
console.log(`MQTT: Connecting ${mqttHost.text}`)
let mqttClient = mqtt.connect("mqtt://" + mqttHost.text, {})

mqttClient.on('connect', ()=>{
console.log(`MQTT: ${mqttHost.text} connected`)
this.statusMessage("conn ok")
})

mqttClient.on('disconnect', ()=>{
console.log(`MQTT: ${mqttHost.text} disconnected`)
this.statusMessage("disc.")
})

mqttClient.on('error', (e)=>{
console.log(`MQTT: ${mqttHost.text} error ${e}`)
this.statusMessage("error")
})


//recursively send all control values to mqtt
function sendControls(topic: string, controlGroup: ControlGroup) {

Expand Down
16 changes: 0 additions & 16 deletions presets/MQTT/default.json

This file was deleted.

2 changes: 1 addition & 1 deletion presets/MQTT/localhost.json → presets/MQTT/hsd.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"value": 60
},
"MQTT host": {
"text": "localhost"
"text": "mqtt.hackerspace-drenthe.nl"
},
"MQTT topic": {
"text": "ledder"
Expand Down

0 comments on commit dacdde9

Please sign in to comment.