Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Fresco_Hydrate_Ultra_Pet_Fountain.yaml #2006

Merged
merged 10 commits into from
Jun 22, 2024

Conversation

malosaa
Copy link
Contributor

@malosaa malosaa commented Jun 12, 2024

Support for Pettadore | Fresco | Hydrate Ultra

Support for Pettadore | Fresco | Hydrate Ultra
These changes should fix the formatting issues and trailing spaces that are causing the linting warnings + adding a fix for the non working waterlevel.
Trailing spaces removed.
Indentation adjusted.
@malosaa
Copy link
Contributor Author

malosaa commented Jun 13, 2024

image

@Fuechslein
Copy link

Tried with my Petoneer Fresco Ultra but couldn't get it to be recognized.

image

@make-all
Copy link
Owner

make-all commented Jun 14, 2024

Tried with my Petoneer Fresco Ultra but couldn't get it to be recognized.

This seems to be a different device despite the similar sounding name.

min: 0
max: 43200
mapping:
- scale: 1440
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of scaling this to days, add class: duration to the entity config, and change the unit to min. Then HA should scale as appropriate.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did not add class: duration to the entity config.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

  - entity: sensor
    name: Filter life
    icon: "mdi:air-filter"
    category: diagnostic
    class: duration
    dps:
      - id: 104
        type: integer
        name: sensor
        range:
          min: 0
          max: 43200
        mapping:
          - invert: true
        unit: min


secondary_entities:
- entity: button
name: Reset Filter Alarm
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "Alarm" to life" here to connect it logically to the sensor below. Including "Alarm" makes it seem like it is connected to an alarm bell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree i can change the name

invert: true
unit: d
- entity: button
name: Reset Pump Alarm
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well i change the name

min: 0
max: 86400
mapping:
- scale: 1440
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with class and scale

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't gonna do that, as it works correct. as well u have another supported fountain that has almost the same config, and there its the same way.

name: sensor
unit: TDS
- entity: switch
name: UV sterilization
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use translation_key: uv_sterilization instead of name and icon to get consistent icon and translations with other tuya-local devices with this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well why does this device need translation_key: uv_sterilization ? as other fountains like the cat fountain whats supported does not have that ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catit_pixi_smart_fountain does have that. I'm not sure which config you are talking about.

category: diagnostic
dps:
- id: 108
type: integer
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dps_val appear to be strings, not integers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not a string but integer.
Uv runtime is no string.

@Fuechslein
Copy link

Tried with my Petoneer Fresco Ultra but couldn't get it to be recognized.

This seems to be a different device despite the similar sounding name.

Hm, okay. Since it looks absolutely identical I was asuming its only a rebrand with the exact same configuration.

@malosaa
Copy link
Contributor Author

malosaa commented Jun 15, 2024

Tried with my Petoneer Fresco Ultra but couldn't get it to be recognized.

This seems to be a different device despite the similar sounding name.

Hm, okay. Since it looks absolutely identical I was asuming its only a rebrand with the exact same configuration.

Well, this is the Petoneer Fresco Ultra, did buy it in germany ;)

@malosaa
Copy link
Contributor Author

malosaa commented Jun 15, 2024

I will fix the code next week, as i am short of time.
But would love that some supported templates are up to date, and they are not.

for me i'm using this for a whileand have 0 problems with last HA update.

@malosaa
Copy link
Contributor Author

malosaa commented Jun 18, 2024

I will revamp the whole code according to your suggestions @make-all
As for now i'm still out of time and can't test yet. i will try to get it done before saturday

make-all added a commit that referenced this pull request Jun 18, 2024
Instead of scaling the values to a more useful unit (days), use the original
value with original min units, and the duration class to get the HA UI
to do the scaling dynamically.

Comment on PR #2006
@malosaa
Copy link
Contributor Author

malosaa commented Jun 21, 2024

Well i'm updating the code, and still this is not working at all:

#2006 (comment)

So if i do this instead, it will work and show the value normal

  - entity: sensor
    name: Filter life
    icon: "mdi:air-filter"
    category: diagnostic
    dps:
      - id: 104
        type: integer
        name: sensor
        precision: 0
        range:
          min: 0
          max: 43200
        mapping:
          - scale: 1440  # minutes => days
            invert: true
        unit: d
        class: duration

this ill show the value 27D and that's correct.

So you really need to help me why your suggestion is not working or me.
Even when removing the scale and use minutes it does not calculate correct.
shows something like this:

37,462 min

the output of the device is this, and i know its minutes, but homeassistant doesn't calculate it.

{
        "code": "filter_alarm",
        "custom_name": "",
        "dp_id": 104,
        "time": 1718975083626,
        "value": 5756
      },

// update

i did notice it works backwards, i did reset the filter and the value became 1 aka 1 minute.
It increases.

so the thing is, what i wanted to do before is decrease, so it shows the days instead of the minutes elapsed.. so we know when its time to clean the filter:

- entity: sensor
  name: Filter life
  icon: "mdi:pump"
  category: diagnostic
  dps:
    - id: 104  
      type: integer
      name: sensor
      precision: 0
      range:
        min: 0
        max: 86400  
      unit: min
      class: duration
``

This works but it increases, shows 7 minutes now, as 7 minutes ago i did press reset.
i want to see if its possible to count down from 30 days instead.




@malosaa
Copy link
Contributor Author

malosaa commented Jun 21, 2024

I think i fixed the code now, but there is a issue i can't resolve.
So normally when adding the device i get a 100% match, but i need to get rid of this line, and i don't know why...

   - entity: switch
     name: UV Light
     icon: "mdi:bacteria"
     category: config
     dps:
       - id: 107
         type: boolean
         name: uv

When i use my new code like this its getting a 100% match:

name: Hydrate Ultra
products:
  - id: cuw2k3ho3e25fade  
    name: Hydrate Ultra

primary_entity:
  entity: light
  icon: "mdi:water-pump"
  dps:
    - id: 101
      type: boolean
      name: switch  
    - id: 102
      name: brightness
      type: integer
      range:
        min: 1
        max: 10

secondary_entities:
  - entity: button
    name: Reset Water
    icon: "mdi:water-circle"
    category: config
    dps:
      - id: 103
        type: integer  
        name: button
  - entity: sensor
    name: Water life
    icon: "mdi:air-filter"
    category: diagnostic
    dps:
      - id: 103
        type: integer
        name: sensor
        precision: 0
        range:
          min: 0
          max: 43200  
        unit: min
        class: duration
  - entity: button
    name: Reset Filter
    icon: "mdi:air-filter"
    category: config
    dps:
      - id: 104
        type: integer  
        name: button
  - entity: sensor
    name: Filter life
    icon: "mdi:air-filter"
    category: diagnostic
    dps:
      - id: 104  
        type: integer
        name: sensor
        precision: 0
        range:
          min: 0
          max: 86400  
        unit: min
        class: duration
  - entity: button
    name: Reset Pump
    icon: "mdi:pump"
    category: config
    dps:
      - id: 105
        type: integer 
        name: button
  - entity: sensor
    name: Pump maintenance
    icon: "mdi:pump"
    category: diagnostic
    dps:
      - id: 105
        type: integer
        name: sensor
        precision: 0
        range:
          min: 0
          max: 43200  
        unit: min
        class: duration
  - entity: sensor
    name: Water quality
    icon: "mdi:water"
    category: diagnostic
    dps:
      - id: 106
        type: integer
        name: sensor
        unit: TDS
#   - entity: switch
#     name: UV Light
#     icon: "mdi:bacteria"
#     category: config
#     dps:
#       - id: 107
#         type: boolean
#         name: uv
  - entity: sensor
    name: Water level
    icon: "mdi:water"
    category: diagnostic
    dps:
      - id: 108
        type: integer
        name: sensor
        mapping:
          - dps_val: "1"
            value: 1
          - dps_val: "2"
            value: 2
          - dps_val: "3"
            value: 3
          - dps_val: "4"
            value: 4
  - entity: sensor
    name: UV runtime
    icon: "mdi:timer-outline"
    category: diagnostic
    dps:
      - id: 109
        type: integer
        name: sensor
        unit: s
        class: duration

debug on 107

      {
        "code": "uv",
        "custom_name": "",
        "dp_id": 107,
        "time": 1718536328821,
        "value": true
      },

@malosaa
Copy link
Contributor Author

malosaa commented Jun 21, 2024

I did fix the full code and it works, however there is an issue i just found out and don't knwo why its happening.

So when i press reset water it resets correct, i see the value going to 0
When pressing the other 2 resets the value goes to 1, and updates device to 1 and reverts back to old value.

It could be probably an issue with the device itself

image

@malosaa
Copy link
Contributor Author

malosaa commented Jun 22, 2024

@make-all

I now know how i can update according to your requests.
So from now on i can help with most unfinished pull requests form months ago.

So i gonna contribute a lot, as i love this integration.
Next contributions will be less messages, as i now fully understand how it all works now.

But i need only to understand how the reset button is working.
As when i press the reset button of the pump and filter, the value of DPS 105 and 104 are set to 1, but when i press the reset on water it sets the value on 0

However when i look the device debug on tuya cloud, it shows the value getting reset, but sets it back to de current one.
Except for water reset, but they basically all the same.
So what i think is that this is a problem with the device itself.

So, with this new code update everything is working, and i did add the translation_key: uv_sterilization for DPS 107 and works correct now :)

Have an nice day.

@make-all
Copy link
Owner

make-all commented Jun 22, 2024

Buttons expect to send true when pushed (from HA point of view). It looks like the reset buttons in this config are of type integer, so I guess they expect that to reset you should send 0, or max. So you need a mapping of HA true to what the dps expects, like:

mapping:
  - dps_val: 0
    value: true

@malosaa
Copy link
Contributor Author

malosaa commented Jun 22, 2024

Buttons expect to send true when pushed (from HA point of view). It looks like the reset buttons in this config are of type integer, so I guess they expect that to reset you should send 0, or max. So you need a mapping of HA true to what the dps expects, like:

mapping:
  - dps_val: 0
    value: true

Yes you right that fix it right away, i will update the code now.

One final question to finish this.
However i did notice now that the change i made for the time value in home assistant is showing wrong after a day has passed.
I did follow your advice, and i implemented it, however after some hours have passed it does say 1,227 min
Is there a way that it shows it nicer, for example 20 hours and 45 minutes

this is what i have

- entity: sensor
    name: Filter life
    icon: "mdi:air-filter"
    category: diagnostic
    dps:
      - id: 104  
        type: integer
        name: sensor
        precision: 0
        range:
          min: 0
          max: 86400  
        unit: min
        class: duration

@malosaa
Copy link
Contributor Author

malosaa commented Jun 22, 2024

i removed the duration class, now it should work.
I go pull the code so i hope you are ok with the modifications.

regards

@make-all
Copy link
Owner

make-all commented Jun 22, 2024

The class: duration needs to be up a level, as part of the entity definition rather than the dps definition.
Without the duration class (in the correct location), HA will not do the auto scaling of times.

malosaa and others added 3 commits June 22, 2024 06:24
Removed class duration from normal statuses.
Fixed the reset buttons
- from review: add duration class correctly
- separate switch and light, since the switch controls the whole device

- unbrand the top level name, include full device name in product specific name.
…petfountain.yaml

Rename file to fit in with most common naming convention (all lowecase, separate parts for brand, model, device type, but multiple words within those not separated.

Not all existing files follow the convention, but the majority do and it is better not to make the inconsistency spread.
@make-all make-all merged commit ecf4de0 into make-all:main Jun 22, 2024
4 checks passed
@malosaa malosaa deleted the malosaa-fresco-1 branch June 22, 2024 18:27
timlaing pushed a commit to timlaing/tuya-local that referenced this pull request Aug 8, 2024
Instead of scaling the values to a more useful unit (days), use the original
value with original min units, and the duration class to get the HA UI
to do the scaling dynamically.

Comment on PR make-all#2006
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants