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

added samsung smartthings plug #286

Merged
merged 8 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
38 changes: 38 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,44 @@ const converters = {
}
},
},
samsung_on_off: {
key: ['state'],
convert: (key, value, message, type, postfix) => {
const cid = 'genOnOff';
const attrId = 'onOff';

let state = value.toLowerCase();
if (state === 'on' ) {
state = 1;
} else if ( state === 'off' ) {
state = 0;
} else {
return;
}

if (type === 'set') {
if (typeof value !== 'string') {
return;
}

return {
cid: cid,
cmd: state,
cmdType: 'functional',
zclData: {},
cfg: cfg.default,
};
} else if (type === 'get') {
return {
cid: cid,
cmd: 'read',
cmdType: 'foundation',
zclData: [{attrId: zclId.attr(cid, attrId).value}],
cfg: cfg.default,
};
}
},
},
on_off: {
key: ['state'],
convert: (key, value, message, type, postfix) => {
Expand Down
19 changes: 19 additions & 0 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,25 @@ const devices = [
execute(device, actions, callback);
},
},
{
zigbeeModel: ['outlet'],
model: 'IM6001-OTP05',
vendor: 'SmartThings',
description: 'Outlet',
supports: 'on/off',
fromZigbee: [fz.state, fz.ignore_onoff_report],
toZigbee: [tz.samsung_on_off],
Copy link
Owner

Choose a reason for hiding this comment

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

Does it also work when using tz.on_off instead of tz.samsung_on_off?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, crashes :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, wrong spot, doesn't crash... nothing happens. the changes i made seem to work.

Copy link
Owner

Choose a reason for hiding this comment

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

I would like to get a better understanding why this doesn't work. Could you post the log with advanced -> log_level: debug with both converters when turning on/off the switch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you want me to change code to
toZigbee: [tz.samsung_on_off, tz.on_off]]
and log... or just
toZigbee: [tz.on_off]]

Copy link
Owner

Choose a reason for hiding this comment

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

just toZigbee: [tz.on_off]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

strange... working now... i swear it didn't first time... perhaps a timing/reload issue (didn't save file properly before reloading).

configure: (ieeeAddr, shepherd, coordinator, callback) => {
const device = shepherd.find(ieeeAddr, 1);
const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 1000, repChange: 0};
const actions = [
(cb) => device.bind('genOnOff', coordinator, cb),
(cb) => device.foundation('genOnOff', 'configReport', [cfg], foundationCfg, cb),
];

execute(device, actions, callback);
},
},

// Trust
{
Expand Down