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

feat: represent terncy scene as a homeassistant swtich #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hzxa21
Copy link
Contributor

@hzxa21 hzxa21 commented Mar 5, 2023

  • Get and parse terncy scene entities
  • Represent the secne as a switch in homeassistant so that it can be turned on and off

Terncy app is more powerful to define actions and combinations than home assistant in some use cases since the app is optimized to controlling Terncy devices. With this feature, I can create a scene to do complex actions and port it in homeassistant. I tested locally and it works smoothly.

This PR also fixes a bug introduced by 9917275:

  • device state is not updated on receiving entity avaiable message

close #24

@hzxa21
Copy link
Contributor Author

hzxa21 commented Mar 5, 2023

cc @rxwen PTAL

@@ -367,6 +370,11 @@ async def update_or_create_entity_inner(svc, tern, model, version, available):
device = TerncyTemperatureSensor(tern, devid + DEVID_EXT_TEMP, name + "-T", model, version, features)
device.is_available = available
await add_entity_to_platform(tern, devid + DEVID_EXT_TEMP, device, attrs, PLATFORM_SENSOR)
elif model == "TERNCY-SCENE":
Copy link
Owner

Choose a reason for hiding this comment

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

It's better to define a const for "TERNCY-SCENE"

@@ -367,6 +370,11 @@ async def update_or_create_entity_inner(svc, tern, model, version, available):
device = TerncyTemperatureSensor(tern, devid + DEVID_EXT_TEMP, name + "-T", model, version, features)
device.is_available = available
await add_entity_to_platform(tern, devid + DEVID_EXT_TEMP, device, attrs, PLATFORM_SENSOR)
elif model == "TERNCY-SCENE":
device = TerncyScene(tern, devid, name, model, version, features)
Copy link
Owner

Choose a reason for hiding this comment

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

We may need to forge a new devid based on the id of the returned scene, and the hub's id.
Because if user pair several different hubs, each of them may return the same scene id. If we use the scene id directly, there might be ambiguation.

For instance, devid = devid + "@" + tern.dev_id

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.

Port scenes into homeassistant
2 participants