mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-07-01 13:32:44 +00:00
Make some custom Modifications for better handling.
This commit is contained in:
parent
8442b1a384
commit
69744121e3
@ -4,8 +4,8 @@ Sensor to check the status of a Minecraft server.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.helpers.entity import Entity
|
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_MOTD = 'MOTD'
|
||||||
ATTR_VERSION = 'Version'
|
ATTR_VERSION = 'Version'
|
||||||
ICON = 'mdi:minecraft'
|
ICON = 'mdi:minecraft'
|
||||||
@ -58,8 +58,8 @@ class MCServerSensor(Entity):
|
|||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
status = self._mcserver.lookup(self._server).status()
|
status = self._mcserver.lookup(self._server).status()
|
||||||
query = self._mcserver.lookup(self._server).query()
|
query = self._mcserver.lookup(self._server).query()
|
||||||
self._state = str(status.players.online) + '/' + str(status.players.max)
|
self._state = str(status.players.online)
|
||||||
self._ping = status.latency
|
self._max = str(status.players.max)
|
||||||
self._users = query.players.names
|
self._users = query.players.names
|
||||||
self._motd = query.motd
|
self._motd = query.motd
|
||||||
self._version = query.software.version
|
self._version = query.software.version
|
||||||
@ -69,8 +69,8 @@ class MCServerSensor(Entity):
|
|||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return {
|
return {
|
||||||
ATTR_PING: self._ping,
|
|
||||||
ATTR_USERS: self._users,
|
ATTR_USERS: self._users,
|
||||||
|
ATTR_MAX: self._max,
|
||||||
ATTR_MOTD: self._motd,
|
ATTR_MOTD: self._motd,
|
||||||
ATTR_VERSION: self._version
|
ATTR_VERSION: self._version
|
||||||
}
|
}
|
||||||
|
@ -31,15 +31,7 @@ automation:
|
|||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: sensor.bear_stone
|
entity_id: sensor.bear_stone
|
||||||
|
to: '1/10'
|
||||||
condition:
|
|
||||||
- condition: template
|
|
||||||
value_template: >
|
|
||||||
{% if not is_state('sensor.bear_stone', '0/10') %}
|
|
||||||
false
|
|
||||||
{% else %}
|
|
||||||
true
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
action:
|
action:
|
||||||
- service: script.notify_engine
|
- service: script.notify_engine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user