python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

Add support chunmi.pre_cooker.eh1

Open ildarunic opened this issue 1 year ago • 0 comments

Hello! You recently added a Multicooker to support chunmi.cooker.eh1. But I have such a multicooker writes that it is chunmi.pre_cooker.eh1. Please add support.

Name of the device: Xiaomi СhunMi IH Rice Cooker 5L

Model: chunmi.pre_cooker.eh1 Hardware version: esp32 Firmware version: 2.0.7_0018

I tried to connect the rice cooker through the repository sschirr/xiaomi_cooker

There was an error in the file xiaomi_cooker/custom_components/xiaomi_miio_cooker/sensor.py in line 71, I replaced the construction locally

@asyncio.coroutine
def async_added_to_hash(self):

on

async def async_added_to_hash(self):

but I get 2 warnings and 4 errors:

******************* Warning 1 ***********************************

Logger: homeassistant.helpers.template
Source: helpers/template.py:684
First occurred: 23:31:55 (2 occurrences)
Last logged: 23:31:55

Template variable warning: 'dict object' has no attribute 'unknown' when rendering '{{ { "0000000000000000000000000000000000000001": "Fine Rice", "0101000000000000000000000000000000000002": "Quick Rice", "0202000000000000000000000000000000000003": "Congee", "0303000000000000000000000000000000000004": "Keep warm", "0505000000000000000000000000000000000009": "Cake" }[states('sensor.xiaomi_miio_cooker_menu')] }}'

************************ Error 1 ****************************

Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:397
First occurred: 23:31:55 (1 occurrences)
Last logged: 23:31:55

TemplateError('ValueError: Template error: int got invalid input 'unknown' when rendering template '{% if is_state('sensor.xiaomi_miio_cooker_mode', 'Waiting') %} 0:00 {% else %} {% if is_state('sensor.xiaomi_miio_cooker_mode', 'PreCook') %} {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) % 60)) | string) }} {% else %} {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_remaining') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_remaining') | int) % 60)) | string) }} {% endif %} {% endif %}' but no default was specified') while processing template 'Template<template=({% if is_state('sensor.xiaomi_miio_cooker_mode', 'Waiting') %} 0:00 {% else %} {% if is_state('sensor.xiaomi_miio_cooker_mode', 'PreCook') %} {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) % 60)) | string) }} {% else %} {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_remaining') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_remaining') | int) % 60)) | string) }} {% endif %} {% endif %}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.cooker_time_remaining'

************************ Error 2 ****************************

Logger: homeassistant.helpers.event
Source: helpers/template.py:565
First occurred: 23:31:55 (1 occurrences)
Last logged: 23:31:55

Error while processing template: Template<template=({% if is_state('sensor.xiaomi_miio_cooker_mode', 'Waiting') %} 0:00 {% else %} {% if is_state('sensor.xiaomi_miio_cooker_mode', 'PreCook') %} {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) % 60)) | string) }} {% else %} {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_remaining') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_remaining') | int) % 60)) | string) }} {% endif %} {% endif %}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 563, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2179, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 7, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1927, in forgiving_int_filter
    raise_no_default("int", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1609, in raise_no_default
    raise ValueError(
ValueError: Template error: int got invalid input 'unknown' when rendering template '{% if is_state('sensor.xiaomi_miio_cooker_mode', 'Waiting') %}
  0:00
{% else %}
  {% if is_state('sensor.xiaomi_miio_cooker_mode', 'PreCook') %}
    {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) % 60)) | string) }}
  {% else %}
    {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_remaining') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_remaining') | int) % 60)) | string) }}
  {% endif %}
{% endif %}' but no default was specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 684, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 565, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: int got invalid input 'unknown' when rendering template '{% if is_state('sensor.xiaomi_miio_cooker_mode', 'Waiting') %}
  0:00
{% else %}
  {% if is_state('sensor.xiaomi_miio_cooker_mode', 'PreCook') %}
    {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_cooking_delayed') | int) % 60)) | string) }}
  {% else %}
    {{ ('%02d' % (((states('sensor.xiaomi_miio_cooker_remaining') | int) / 60) | int)) | string + ':' + ( ('%02d' % ((states('sensor.xiaomi_miio_cooker_remaining') | int) % 60)) | string) }}
  {% endif %}
{% endif %}' but no default was specified

************************ Error 3 ****************************

Logger: homeassistant.setup
Source: setup.py:398
First occurred: 23:31:42 (1 occurrences)
Last logged: 23:31:42

Unable to prepare setup for platform xiaomi_miio_cooker.sensor: Unable to set up component.

************************ Error 4 ****************************

Logger: homeassistant.setup
Source: custom_components/xiaomi_miio_cooker/__init__.py:154
Integration: Xiaomi Mi Electric Rice Cooker ([documentation](https://github.com/syssi/xiaomi_cooker), [issues](https://github.com/syssi/xiaomi_cooker/issues))
First occurred: 23:31:42 (1 occurrences)
Last logged: 23:31:42

Error during setup of component xiaomi_miio_cooker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 288, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miio_cooker/__init__.py", line 169, in setup
    update(utcnow())
  File "/config/custom_components/xiaomi_miio_cooker/__init__.py", line 154, in update
    state = cooker.status()
            ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 184, in _wrap
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/miio/cooker_multi.py", line 369, in status
    values.append(self.send("get_prop", [prop])[0])
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

******************* Warning 2 *********************************** Found an unsupported model 'chunmi.pre_cooker.eh1' for class 'MultiCooker'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/

ildarunic avatar Aug 12 '23 21:08 ildarunic