From 69744121e37a3824f3a412cc2c72dfaf64a9106a Mon Sep 17 00:00:00 2001 From: ccostan Date: Thu, 1 Feb 2018 15:54:03 -0500 Subject: [PATCH] Make some custom Modifications for better handling. --- custom_components/sensor/minecraft.py | 10 +++++----- packages/minecraft.yaml | 10 +--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/custom_components/sensor/minecraft.py b/custom_components/sensor/minecraft.py index fa8e1724..cecc4724 100755 --- a/custom_components/sensor/minecraft.py +++ b/custom_components/sensor/minecraft.py @@ -4,8 +4,8 @@ Sensor to check the status of a Minecraft server. """ import logging from homeassistant.helpers.entity import Entity -ATTR_PING = 'Ping' -ATTR_USERS = 'Users Online' +ATTR_USERS = 'users_online' +ATTR_MAX = 'users_max' ATTR_MOTD = 'MOTD' ATTR_VERSION = 'Version' ICON = 'mdi:minecraft' @@ -58,8 +58,8 @@ class MCServerSensor(Entity): """Update device state.""" status = self._mcserver.lookup(self._server).status() query = self._mcserver.lookup(self._server).query() - self._state = str(status.players.online) + '/' + str(status.players.max) - self._ping = status.latency + self._state = str(status.players.online) + self._max = str(status.players.max) self._users = query.players.names self._motd = query.motd self._version = query.software.version @@ -69,8 +69,8 @@ class MCServerSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_PING: self._ping, ATTR_USERS: self._users, + ATTR_MAX: self._max, ATTR_MOTD: self._motd, ATTR_VERSION: self._version } diff --git a/packages/minecraft.yaml b/packages/minecraft.yaml index 2d6e802a..da120c81 100755 --- a/packages/minecraft.yaml +++ b/packages/minecraft.yaml @@ -31,15 +31,7 @@ automation: trigger: - platform: state entity_id: sensor.bear_stone - - condition: - - condition: template - value_template: > - {% if not is_state('sensor.bear_stone', '0/10') %} - false - {% else %} - true - {% endif %} + to: '1/10' action: - service: script.notify_engine