Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed availability, force_devices types, light #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion warema-bridge/rootfs/srv/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ function registerDevice(element) {
set_position_topic: 'warema/' + element.snr + '/set_position',
}
break
case 1000:
topic = 'homeassistant/light/' + element.snr + '/' + element.snr + '/config'
model = 'LED Stripes'
payload = {
...base_payload,
device: {
...base_device,
model: model
},
command_topic: 'warema/' + element.snr + '/switch',
brightness_state_topic: 'warema/' + element.snr + '/position',
brightness_command_topic: 'warema/' + element.snr + '/set_brightness',
on_command_type: 'brightness',
payload_off: 'off',
payload_on: 'on',
state_topic: 'warema/' + element.snr + '/state',
brightness_scale: '100',
}
break
default:
console.log('Unrecognized device type: ' + element.type)
model = 'Unknown model ' + element.type
Expand All @@ -133,7 +152,7 @@ function registerDevice(element) {
function registerDevices() {
if (forceDevices && forceDevices.length) {
forceDevices.forEach(element => {
registerDevice({snr: element, type: 25})
registerDevice({snr: element.split(':')[0], type: element.split(':')[1] ? element.split(':')[1] : 25 })
})
} else {
console.log('Scanning...')
Expand Down Expand Up @@ -240,6 +259,7 @@ client.on('connect', function (connack) {
{},
callback
);
client.publish('warema/bridge/state', 'online', {retain: true})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be published in the wms-vb-init-completion handler (line 169)

})

client.on('error', function (error) {
Expand Down Expand Up @@ -272,6 +292,14 @@ client.on('message', function (topic, message) {
case 'set_tilt':
stickUsb.vnBlindSetPosition(device, parseInt(shade_position[device]['position']), parseInt(message))
break
case 'switch':
stickUsb.vnBlindStop(device)
client.publish('warema/'+ device+ '/state', 'off', {retain: true})
break
case 'set_brightness':
stickUsb.vnBlindSetPosition(device, parseInt(message), parseInt(shade_position[device]['angle']))
client.publish('warema/'+ device+ '/state', 'on', {retain: true})
break
//default:
// console.log('Unrecognised command from HA')
}
Expand Down
Loading