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

Commit

Permalink
Update stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Nov 10, 2019
1 parent 894b962 commit ac54b72
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 156 deletions.
17 changes: 0 additions & 17 deletions .devcontainer/Dockerfile

This file was deleted.

53 changes: 0 additions & 53 deletions .devcontainer/README.md

This file was deleted.

26 changes: 0 additions & 26 deletions .devcontainer/custom_component_helper

This file was deleted.

17 changes: 12 additions & 5 deletions .devcontainer/devcontainer.json
@@ -1,19 +1,26 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "Custom integration authenticated",
"image": "ludeeus/devcontainer:integration",
"context": "..",
"dockerFile": "Dockerfile",
"appPort": "8124:8123",
"appPort": [
"9123:8123"
],
"postCreateCommand": "dc install",
"runArgs": [
"-e",
"GIT_EDTIOR='code --wait'"
"-v",
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh" // This is added so you can push from inside the container
],
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"tabnine.tabnine-vscode"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
Expand Down
Binary file removed .devcontainer/images/reopen.png
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.pyc
48 changes: 8 additions & 40 deletions .vscode/tasks.json
Expand Up @@ -2,59 +2,27 @@
"version": "2.0.0",
"tasks": [
{
"label": "Start Home Assistant on port 8124",
"label": "Run Home Assistant on port 9123",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && StartHomeAssistant",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"command": "dc start",
"problemMatcher": []
},
{
"label": "Upgrade Home Assistant to latest dev",
"label": "Run Home Assistant configuration against /config",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && UpdgradeHomeAssistantDev",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"command": "dc check",
"problemMatcher": []
},
{
"label": "Set Home Assistant Version",
"label": "Upgrade Home Assistant to latest dev",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && SetHomeAssistantVersion",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"command": "dc start",
"problemMatcher": []
},
{
"label": "Home Assistant Config Check",
"label": "Install a spesific version of Home Assistant",
"type": "shell",
"command": "source .devcontainer/custom_component_helper && HomeAssistantConfigCheck",
"group": {
"kind": "test",
"isDefault": true,
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"command": "dc set-version",
"problemMatcher": []
}
]
Expand Down
31 changes: 16 additions & 15 deletions custom_components/authenticated/sensor.py
Expand Up @@ -182,6 +182,8 @@ def update(self):

if new == stored:
continue
if new is None or stored is None:
continue
elif new > stored:
updated = True
_LOGGER.info("New successfull login from known IP (%s)", access)
Expand Down Expand Up @@ -322,25 +324,24 @@ def load_authentications(authfile, exclude):
if ValidateIP(token["last_used_ip"]) in ip_network(
excludeaddress, False
):
break
else:
if token["last_used_ip"] in tokens_cleaned:
if (
token["last_used_at"]
> tokens_cleaned[token["last_used_ip"]]["last_used_at"]
):
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
"last_used_at"
]
tokens_cleaned[token["last_used_ip"]]["user_id"] = token[
"user_id"
]
else:
tokens_cleaned[token["last_used_ip"]] = {}
continue
if token.get("last_used_at") is None:
continue
if token["last_used_ip"] in tokens_cleaned:
if (
token["last_used_at"]
> tokens_cleaned[token["last_used_ip"]]["last_used_at"]
):
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
"last_used_at"
]
tokens_cleaned[token["last_used_ip"]]["user_id"] = token["user_id"]
else:
tokens_cleaned[token["last_used_ip"]] = {}
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
"last_used_at"
]
tokens_cleaned[token["last_used_ip"]]["user_id"] = token["user_id"]
except Exception: # Gotta Catch 'Em All
pass

Expand Down

0 comments on commit ac54b72

Please sign in to comment.