Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit ac54b72

Browse files
committed
Update stuff
1 parent 894b962 commit ac54b72

File tree

8 files changed

+37
-156
lines changed

8 files changed

+37
-156
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

.devcontainer/README.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

.devcontainer/custom_component_helper

Lines changed: 0 additions & 26 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
22
{
3+
"name": "Custom integration authenticated",
4+
"image": "ludeeus/devcontainer:integration",
35
"context": "..",
4-
"dockerFile": "Dockerfile",
5-
"appPort": "8124:8123",
6+
"appPort": [
7+
"9123:8123"
8+
],
9+
"postCreateCommand": "dc install",
610
"runArgs": [
7-
"-e",
8-
"GIT_EDTIOR='code --wait'"
11+
"-v",
12+
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh" // This is added so you can push from inside the container
913
],
1014
"extensions": [
1115
"ms-python.python",
1216
"github.vscode-pull-request-github",
1317
"tabnine.tabnine-vscode"
1418
],
1519
"settings": {
16-
"python.pythonPath": "/usr/local/bin/python",
20+
"files.eol": "\n",
21+
"editor.tabSize": 4,
22+
"terminal.integrated.shell.linux": "/bin/bash",
23+
"python.pythonPath": "/usr/bin/python3",
1724
"python.linting.pylintEnabled": true,
1825
"python.linting.enabled": true,
1926
"python.formatting.provider": "black",

.devcontainer/images/reopen.png

-7.99 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

.vscode/tasks.json

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,27 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "Start Home Assistant on port 8124",
5+
"label": "Run Home Assistant on port 9123",
66
"type": "shell",
7-
"command": "source .devcontainer/custom_component_helper && StartHomeAssistant",
8-
"group": {
9-
"kind": "test",
10-
"isDefault": true,
11-
},
12-
"presentation": {
13-
"reveal": "always",
14-
"panel": "new"
15-
},
7+
"command": "dc start",
168
"problemMatcher": []
179
},
1810
{
19-
"label": "Upgrade Home Assistant to latest dev",
11+
"label": "Run Home Assistant configuration against /config",
2012
"type": "shell",
21-
"command": "source .devcontainer/custom_component_helper && UpdgradeHomeAssistantDev",
22-
"group": {
23-
"kind": "test",
24-
"isDefault": true,
25-
},
26-
"presentation": {
27-
"reveal": "always",
28-
"panel": "new"
29-
},
13+
"command": "dc check",
3014
"problemMatcher": []
3115
},
3216
{
33-
"label": "Set Home Assistant Version",
17+
"label": "Upgrade Home Assistant to latest dev",
3418
"type": "shell",
35-
"command": "source .devcontainer/custom_component_helper && SetHomeAssistantVersion",
36-
"group": {
37-
"kind": "test",
38-
"isDefault": true,
39-
},
40-
"presentation": {
41-
"reveal": "always",
42-
"panel": "new"
43-
},
19+
"command": "dc start",
4420
"problemMatcher": []
4521
},
4622
{
47-
"label": "Home Assistant Config Check",
23+
"label": "Install a spesific version of Home Assistant",
4824
"type": "shell",
49-
"command": "source .devcontainer/custom_component_helper && HomeAssistantConfigCheck",
50-
"group": {
51-
"kind": "test",
52-
"isDefault": true,
53-
},
54-
"presentation": {
55-
"reveal": "always",
56-
"panel": "new"
57-
},
25+
"command": "dc set-version",
5826
"problemMatcher": []
5927
}
6028
]

custom_components/authenticated/sensor.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ def update(self):
182182

183183
if new == stored:
184184
continue
185+
if new is None or stored is None:
186+
continue
185187
elif new > stored:
186188
updated = True
187189
_LOGGER.info("New successfull login from known IP (%s)", access)
@@ -322,25 +324,24 @@ def load_authentications(authfile, exclude):
322324
if ValidateIP(token["last_used_ip"]) in ip_network(
323325
excludeaddress, False
324326
):
325-
break
326-
else:
327-
if token["last_used_ip"] in tokens_cleaned:
328-
if (
329-
token["last_used_at"]
330-
> tokens_cleaned[token["last_used_ip"]]["last_used_at"]
331-
):
332-
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
333-
"last_used_at"
334-
]
335-
tokens_cleaned[token["last_used_ip"]]["user_id"] = token[
336-
"user_id"
337-
]
338-
else:
339-
tokens_cleaned[token["last_used_ip"]] = {}
327+
continue
328+
if token.get("last_used_at") is None:
329+
continue
330+
if token["last_used_ip"] in tokens_cleaned:
331+
if (
332+
token["last_used_at"]
333+
> tokens_cleaned[token["last_used_ip"]]["last_used_at"]
334+
):
340335
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
341336
"last_used_at"
342337
]
343338
tokens_cleaned[token["last_used_ip"]]["user_id"] = token["user_id"]
339+
else:
340+
tokens_cleaned[token["last_used_ip"]] = {}
341+
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
342+
"last_used_at"
343+
]
344+
tokens_cleaned[token["last_used_ip"]]["user_id"] = token["user_id"]
344345
except Exception: # Gotta Catch 'Em All
345346
pass
346347

0 commit comments

Comments
 (0)