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

added moving state to home assistant for TS130F Curtain/blind switch #15555

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

cmiguelcabral
Copy link
Contributor

Curtain/blind switches like TS130F (https://www.zigbee2mqtt.io/devices/TS130F.html#tuya-ts130f) do not show the moving status on the home assistant. This happens because they use a different property to report the moving state, this property is called 'moving'.
This PR reuses the logic for the 'motorState' property (that some other cover switches might use) to report the cover moving state to the home assistant. It was already tested and it's working.
Also, I made some minor adjustments to the docker-compose file to make it possible to build the image directly using it.
Feel free to change something that you don't like or prefer in a different way, or just leave comments and I'll do it.

@cmiguelcabral cmiguelcabral force-pushed the ts130f_compatibility branch 5 times, most recently from dc20650 to d4139ad Compare December 15, 2022 02:13
@Koenkk
Copy link
Owner

Koenkk commented Dec 15, 2022

Can you remove the docker-compose.yml changes? (https://github.com/Koenkk/zigbee2mqtt/pull/15555/files)

@cmiguelcabral cmiguelcabral force-pushed the ts130f_compatibility branch 3 times, most recently from 1f1b440 to fa23b5c Compare December 16, 2022 00:35
@cmiguelcabral
Copy link
Contributor Author

cmiguelcabral commented Dec 16, 2022

Can you remove the docker-compose.yml changes? (https://github.com/Koenkk/zigbee2mqtt/pull/15555/files)

Sure, just removed it.

I went a bit further, but don't know if you want so many changes.
It would be this:
image

If you like it, I can commit and push it, if not, just leave the PR the way it is....

@Koenkk
Copy link
Owner

Koenkk commented Dec 17, 2022

What extra functionality does this bring?

@cmiguelcabral
Copy link
Contributor Author

cmiguelcabral commented Dec 18, 2022

What extra functionality does this bring?

When you use only the 'moving' property of the device, you force the Home Assistant to make a prediction of the state when the cover is stopped, that's called the optimistic approach. And has an impact on performance, not that you'll notice, but it's there.
When you use the state reported by the device (what I'm doing in this second approach), you don't need Home Assistant to do any prediction, only to read the state reported by the device.
So, what you'll get in the PR is a device that reports UP/DOWN/STOP, while in this second approach you'll get UP/DOWN/OPEN/CLOSED.
So, no new functionality, only better practices.
But like I said, this is no big deal, so if you want just leave the PR as it is...

@cmiguelcabral
Copy link
Contributor Author

cmiguelcabral commented Dec 18, 2022

Ah...forget about the try...catch thing, it does nothing, what I'm talking about is only related to the 'openState' and 'closeState'.

@Koenkk
Copy link
Owner

Koenkk commented Dec 18, 2022

Sounds good! Please add it to the pr

@cmiguelcabral cmiguelcabral force-pushed the ts130f_compatibility branch 2 times, most recently from 584510c to 357d99a Compare December 18, 2022 16:28
@cmiguelcabral
Copy link
Contributor Author

cmiguelcabral commented Dec 18, 2022

Sounds good! Please add it to the pr

done

{
  ...
  "state_closed": "CLOSE",
  "state_closing": "DOWN",
  "state_open": "OPEN",
  "state_opening": "UP",
  "value_template": "{{ value_json.moving if value_json.moving and value_json.moving != 'STOP' else value_json.state }}",
}

@Koenkk Koenkk merged commit cce7890 into Koenkk:master Dec 19, 2022
@Koenkk
Copy link
Owner

Koenkk commented Dec 19, 2022

Thanks!

Koenkk pushed a commit that referenced this pull request Dec 19, 2022
@cmiguelcabral cmiguelcabral deleted the ts130f_compatibility branch December 19, 2022 21:10
@convicte
Copy link

convicte commented Jan 2, 2023

@cmiguelcabral, would you consider expanding the PR to devices that are nearly identical, but currently do not benefit from this change?
Namely, the T130F also comes in the dual variant (Dual curtain/blind module (TS130F_dual)) with a moving_left and moving_right.
image

image

As it stands, the PR doesn't fix the behavior of these modules.
I'd be happy to provide information on the particular attributes of these modules, if you can tell me what you need.

@cmiguelcabral
Copy link
Contributor Author

@cmiguelcabral, would you consider expanding the PR to devices that are nearly identical, but currently do not benefit from this change? Namely, the T130F also comes in the dual variant (Dual curtain/blind module (TS130F_dual)) with a moving_left and moving_right. image

image

As it stands, the PR doesn't fix the behavior of these modules. I'd be happy to provide information on the particular attributes of these modules, if you can tell me what you need.

Hi,

Actually, I just ordered two of those. :-)
Let them arrive and I'll do it.
It's better to do it with the device in hands to test than to do it blindly.

@convicte
Copy link

convicte commented Jan 2, 2023

Thanks for the prompt response!
I have 13 of both types, so one could say I am heavily invested.
If I am not mistaken, we've 'worked' before on the motor_inverse and cover direction bug for the T130F line
I'd be happy to assist as best I can.

@Koenkk
Copy link
Owner

Koenkk commented Jan 6, 2023

I had to revert this PR since it broke some Xiaomi covers: #15873

Koenkk added a commit that referenced this pull request Jan 6, 2023
@cmiguelcabral
Copy link
Contributor Author

cmiguelcabral commented Jan 6, 2023

Looks like those covers report stopped instead of stop.
I guess that can be fixed using a mapping like you're doing for open and closed states. But for that, we need to know beforehand all the possibilities.
The thing is that, without this PR, the covers like the ts130f and maybe others (tuya?) don't report they are moving, so you cannot stop them from HA, they go all the way up/down, or to the position you set, but you won't be able to stop the movement (what can be a bit dangerous).

@cmiguelcabral
Copy link
Contributor Author

cmiguelcabral commented Jan 6, 2023

Or maybe another fix could be making it as it did at first and using only the moving property.
I'll try to do it if some of the guys that reported are in the will the help me do it.

@cmiguelcabral cmiguelcabral restored the ts130f_compatibility branch January 7, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants