Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.
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
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ verify_ssl = true
[dev-packages]

[packages]
o365 = "==2.0.9"
o365 = "==2.0.14"
beautifulsoup4 = "==4.9.0"

[requires]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Under "Api Permissions" add the following delegated permission from the Microsof
* Mail.ReadWrite.Shared - *Read and write user and shared mail*
* Mail.Send - *Send mail as a user*
* Mail.Send.Shared - *Send mail on behalf of others*
* Presence.Read - *Allow access to teams status*

## Adding to Home Assistant

Expand Down
2 changes: 1 addition & 1 deletion custom_components/o365/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"documentation": "https://github.com/PTST/O365Calendar-HomeAssistant",
"dependencies": ["configurator", "http"],
"codeowners": ["@PTST"],
"requirements": ["O365==2.0.9", "BeautifulSoup4==4.8.2"]
"requirements": ["O365==2.0.14", "BeautifulSoup4==4.8.2"]
}
25 changes: 25 additions & 0 deletions custom_components/o365/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
sensor = O365QuerySensor(account, conf)
add_devices([sensor], True)

teamsStatusSensor = O365TeamsStatusSensor(account, conf)
add_devices([teamsStatusSensor], True)

class O365QuerySensor(Entity):
def __init__(self, account, conf):
Expand Down Expand Up @@ -183,3 +185,26 @@ def update(self):
self._state = len(mails)
# self._attributes = {"data": attrs, "data_str_repr": json.dumps(attrs)}
self._attributes = {"data": attrs}

class O365TeamsStatusSensor(Entity):
def __init__(self, account, conf):
self.account = account
self.teams = account.teams()
self._name = f"{self.account.get_current_user().mail}-teams status"
self._state = 0
self._attributes = {}

@property
def name(self):
return self._name

@property
def state(self):
return self._state

@property
def device_state_attributes(self):
return self._attributes

def update(self):
self._state = self.teams.get_my_presence().activity