Skip to content

Commit

Permalink
feat(): add authCode configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
deblockt committed Jun 1, 2020
1 parent ef23efa commit 0b85e37
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ vacuum:
host: "<vacuum-ip>"
deviceId: ""
token: ""
authCode: ""
userId: ""
name: ""
sleep_duration_on_exit: # default 60. number of second waiting before reconnection (if you use proscenic app)
```
deviceId, token and userId can be retrieved using the Proscenic robotic application :
Expand All @@ -42,11 +44,12 @@ deviceId, token and userId can be retrieved using the Proscenic robotic applicat
3. Open the proscenic application, and open the vacuum view
4. Reopen Packet capture
1. click on the first line
2. click on the line `47.91.67.181:20008`
3. get you informations ![screenshot](./doc/packet_with_info.png)
5. you can add you vacuum on lovelace ui entities
2. click on the line `<your_vacuum_ip>:8888`
3. get you informations ![screenshot](./doc/packet_with_info.jpg)
5. you can add your vacuum on lovelace ui entities

## Know issue

- At home assistant startup the vacuum cleaner if not retrieved. You should perform an action on home assistant to get le vacuum cleaner status.
- At home assistant startup the vacuum cleaner status is not retrieved. You should perform an action on home assistant to get the vacuum cleaner status.
- If you start the proscenic application, the status of the vacuum cleaner will not be refreshed on home assistant for 60 seconds.
- If you start the proscenic application, you will be disconnected 60 seconds later. You can configure this time using `sleep_duration_on_exit` configuration.
7 changes: 6 additions & 1 deletion custom_components/proscenic/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
CONF_DEVICE_ID = 'deviceId'
CONF_TOKEN = 'token'
CONF_USER_ID = 'userId'
CONF_SLEEP = 'sleep_duration_on_exit'
CONF_AUTH_CODE = 'authCode'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_DEVICE_ID): cv.string,
vol.Required(CONF_TOKEN): cv.string,
vol.Required(CONF_USER_ID): cv.string,
vol.Required(CONF_AUTH_CODE): cv.string,
vol.Optional(CONF_SLEEP, default = 60): int,
vol.Optional(CONF_NAME): cv.string
})

Expand All @@ -79,9 +83,10 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
CONF_DEVICE_ID: config[CONF_DEVICE_ID],
CONF_TOKEN: config[CONF_TOKEN],
CONF_USER_ID: config[CONF_USER_ID],
CONF_AUTH_CODE: config[CONF_AUTH_CODE]
}
name = config[CONF_NAME] if CONF_NAME in config else '790T vacuum'
device = Vacuum(config[CONF_HOST], auth, loop = hass.loop)
device = Vacuum(config[CONF_HOST], auth, loop = hass.loop, config = {CONF_SLEEP: config[CONF_SLEEP]})
vacuums = [ProscenicVacuum(device, name)]
hass.loop.create_task(device.listen_state_change())

Expand Down
10 changes: 7 additions & 3 deletions custom_components/proscenic/vacuum_proscenic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ async def _send_command(self, command: bytes, input_writer = None):
writer = input_writer

header = b'\xd2\x00\x00\x00\xfa\x00\xc8\x00\x00\x00\xeb\x27\xea\x27\x00\x00\x00\x00\x00\x00'
body = b'{"cmd":0,"control":{"authCode":"252997","deviceIp":"' \
body = b'{"cmd":0,"control":{"authCode":"' \
+ str.encode(self.auth['authCode']) \
+ b'","deviceIp":"' \
+ str.encode(self.ip) \
+ b'","devicePort":"8888","targetId":"' \
+ str.encode(self.auth['deviceId']) \
+ b'","targetType":"3"},"seq":0,"value":{' \
+ b'","targetType":"3"},"seq":0,"value":' \
+ command \
+ b'},"version":"1.5.11"}'
+ b',"version":"1.5.11"}'
_LOGGER.debug('send command {}'.format(str(body)))
writer.write(header + body)
await writer.drain()
Expand Down Expand Up @@ -121,6 +123,8 @@ async def _wait_for_state_refresh(self, reader):
async def verify_vacuum_online(self):
try:
await self._send_command(b'{"transitCmd":"131"}')
if self.work_state == WorkState.POWER_OFF or self.work_state == WorkState.OTHER_POWER_OFF:
self.work_state = WorkState.PENDING
except VacuumUnavailable:
self.work_state = WorkState.POWER_OFF
self._call_listners()
Expand Down
Binary file added doc/packet_with_info.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/packet_with_info.png
Binary file not shown.

0 comments on commit 0b85e37

Please sign in to comment.