-
Notifications
You must be signed in to change notification settings - Fork 4
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
Shutter changes #18
base: master
Are you sure you want to change the base?
Shutter changes #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,35 @@ char* MqttHass::newMessageJson(const Device* device, char* buf) { | |
"}", | ||
device->getName(), device->getName(), device->getName(), | ||
device->getName(), device->getName()); | ||
} else { | ||
} else if (device->getMode() == SHUTTER) { | ||
sprintf(buf, | ||
"{" | ||
"\"name\":\"Shutter %s\"," | ||
"\"optimistic\":\"false\"," // if false, cannot know the status | ||
// of the device | ||
"\"cmd_t\":\"~cmnd/POWER\"," | ||
"\"state_topic\":\"~tele/STATE\"," | ||
"\"val_tpl\":\"{{value_json.POWER}}\"," | ||
// "\"tilt_status_topic\": \"~tele/TILT\"," | ||
// "\"tilt_status_template\":\"{{value_json.TILT}}\"," | ||
"\"avty_t\":\"~tele/LWT\"," | ||
"\"pl_avail\":\"Online\"," | ||
"\"pl_not_avail\":\"Offline\"," | ||
"\"payload_close\":\"OFF\"," | ||
"\"payload_open\":\"ON\"," | ||
"\"payload_stop\":\"PAUSE\"," | ||
"\"uniq_id\":\"esp-%s\"," | ||
"\"device\":{" | ||
"\"name\":\"%s\"," | ||
"\"identifiers\":[\"esp-%s\"]," | ||
"\"model\":\"MVR500ERP \"," | ||
"\"mf\":\"Yokis\"" | ||
"}," | ||
"\"~\":\"%s/\"" | ||
"}", | ||
device->getName(), device->getName(), device->getName(), | ||
device->getName(), device->getName()); | ||
} else { | ||
sprintf(buf, | ||
"{" | ||
"\"name\":\"%s switch\"," | ||
|
@@ -88,7 +116,11 @@ char* MqttHass::newMessageJson(const Device* device, char* buf) { | |
} | ||
|
||
char* MqttHass::newPublishTopic(const Device* device, char* buf) { | ||
sprintf(buf, "%s/light/%s/config", HASS_PREFIX, device->getName()); | ||
if (device->getMode() == SHUTTER) { | ||
sprintf(buf, "%s/cover/%s/config", HASS_PREFIX, device->getName()); | ||
} else { | ||
sprintf(buf, "%s/light/%s/config", HASS_PREFIX, device->getName()); | ||
} | ||
return buf; | ||
} | ||
|
||
|
@@ -169,6 +201,9 @@ void MqttHass::subscribeDevice(const Device* device) { | |
this->subscribe(buf); | ||
sprintf(buf, "%s/cmnd/BRIGHTNESS", device->getName()); | ||
this->subscribe(buf); | ||
} else if (device->getMode() == SHUTTER) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, this was missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree so far, maybe in future I can implement the recall saved position here. |
||
sprintf(buf, "%s/cmnd/POWER", device->getName()); | ||
this->subscribe(buf); | ||
} | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test this on Yokis lights to see if this is working as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting back my original comment:
My devices are connected together in a bus.
I figured out that if I send:
B9 06 00 00 00 00 ?? 00 00 (for example) one is moving
B9 16 00 00 00 00 ?? 00 00 (for example) all are moving
I always address the device I want to move because of the implementation of the commands.
Now from our discussion I'm thinking that maybe if I address another device (gateway), but put the address of the device I want to drive in the command, such as:
B9 06 00 00 (address of device) ?? 00 00 sent to the gateway
or maybe:
B9 06 00 20 (address of device) ?? 00 sent to the gateway
The other device may move? Gateway device propagate the command through the bus?
That could be interesting because it allows the mqtt gateway to be far away of some devices.
I didn't tested it. I saw this 0x20 on your firmware but I guess we have different setup.
I'm pretty sure it's possible to test it with other devices, using simple commands such as ON, and
B9 04 or B9 14 to address all.
If it's working as I expect it's a bigger change because the mqtt gateway could try to address any device it knows that is flagged as "part of bus" to reach transparently another one.
I don't think I can configure my Yokis remote to address a specific device through the bus. Maybe with another "intelligent" Yokis remote.