'Get the latest value for this sensor.'

def update(self):

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
        sock.settimeout(self._config[CONF_TIMEOUT])
        try:
            sock.connect((self._config[CONF_HOST], self._config[CONF_PORT]))
        except socket.error as err:
            _LOGGER.error('Unable    to    connect    to    %s    on    port    %s:    %s', self._config[CONF_HOST], self._config[CONF_PORT], err)
            return
        try:
            sock.send(self._config[CONF_PAYLOAD].encode())
        except socket.error as err:
            _LOGGER.error('Unable    to    send    payload    %r    to    %s    on    port    %s:    %s', self._config[CONF_PAYLOAD], self._config[CONF_HOST], self._config[CONF_PORT], err)
            return
        (readable, _, _) = select.select([sock], [], [], self._config[CONF_TIMEOUT])
        if (not readable):
            _LOGGER.warning('Timeout    (%s    second(s))    waiting    for    a    response    after    sending    %r    to    %s    on    port    %s.', self._config[CONF_TIMEOUT], self._config[CONF_PAYLOAD], self._config[CONF_HOST], self._config[CONF_PORT])
            return
        value = sock.recv(self._config[CONF_BUFFER_SIZE]).decode()
    if (self._config[CONF_VALUE_TEMPLATE] is not None):
        try:
            self._state = self._config[CONF_VALUE_TEMPLATE].render(value=value)
            return
        except TemplateError as err:
            _LOGGER.error('Unable    to    render    template    of    %r    with    value:    %r', self._config[CONF_VALUE_TEMPLATE], value)
            return
    self._state = value
