#Flexit Bacnet
1 messages ยท Page 1 of 1 (latest)
Boom!
Let me pull up your code real quick when I'm back at my pc
ah
Right
so since its a new itnegration
you have to use _attr_has_entity_name which you do
This means it will prefix the entity name with the device name
I see!
For example for a device that has sensors it would be
{device} temperature
which makes snese
Yeah, it does
but in your case you have you device set correctly
but
the name of the entity is the same
so swap
Exactly
@property
def name(self) -> str:
"""Name of the entity."""
return self._device.device_name
with
_attr_name = None
With name set to None you are explicitly saying the entity name should be the device name
Sure, fire away
sec...
left another small thing on the PR btw. I probably reviewed the PR when I was in the train r smth and I knew this was a thing but couldn't remember
Okay, will check that out.
You wrote in the PR to inline the function validate_input do you mean as to remove the function and do the stuff in the if-statement directly?
Like, the validate_input function is something that is created by the scaffold script
and in many cases, the code that is executed is just a few lines
Okay. Will remove the function. Now I saw your thing about PRECISION.
device = FlexitBACnet(user_input[CONF_IP_ADDRESS], user_input[CONF_DEVICE_ID])
try:
await device.update()
except (asyncio.exceptions.TimeoutError, ConnectionError, DecodingError):
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
I fixed some of the stuff you commented on. Github confuses me though, think I somehow ended up reviewing my own PR.
I agree
haha, you can press Review changes at the top right and click leave comment
That is what I think I did ๐
But I have to say, this was a very good first shot on a PR
It was not the first shot. I'm continuing the work of another developer. I want this integration really bad since I have a flexit device. Also I'm a Javascript developer, not a python developer...
No but I mean, sometimes when people come up with these kind of PRs that are continuations and then it's still meh
do you want a script so you can run it on your own prod env?
cd /config
curl -o- -L https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d flexit_bacnet -p 104275
I think in a recent SSH update the /config dir was replaced with /homeassistant maybe check which one you need
Oh, another question. I really dont understand the local dev env. Do I really have to restart home assistant every time I'm doing a change in the code? It is really frustrating.
Also it is not very well documented.
but this pulls the git repo, then copies the provided component and installs it as custom component
Yep
It's sadly not as flashy as vite or something
What I'm used to ๐
Vue developer?
React
ah
Gatsby, CRA and NextJs
Ah nice
Yea I work with Vue in general
Recently worked on my first TS backend, which was also quite nice
So compared to node land, python is... really messy.
I mean, the tooling is getting really nice tho
I'm beginning to migrate from JS to TS in my projects at work.
Like I prefer any python tooling over eslint
Like Ruff, is a linter and formatter built in Rust
it formats
the whole code base
(!)
in 0.43 s
The thing with JS is the developer experience. But python can run on a ESP8266 (!). Python is really nice with all libs and all -if you get it to run at all ๐
hahaha
Like, I still miss this with Javascript and all their kind of libs
But now I started with my internship and my goal is to make application configurable
And at this point I am really pushing some HA concepts like making structures with YAML config
Good for you!
or json for that matter
OMG
structures -> pages
Now you lost me
Well, currently all our applications are custom made
Yes
And they share some code, but its still custom
And we want consultants to be able to customize look and feel, and what information is displayed
but still being able to do something custom
And this is where I really like HA's way of being able to serialize your whole dashboard in YAML
A hard problem I guess.
and you can use custom component types for example
Yeah, for sure
I love HA. Been using it in production for five years now.
With ESP's and everything
Yep, it's amazing
Although my biggest gap is that I am now like a jehova's witness
when I walk in a friends home who doesn't use HA yet and I see 2+ things that can be connected
"May I tell you about our lord and saviour Home Assistant?"
So I kinda understand HA from a users point of view, now I'm trying to understand it from a developers point of view... Steep learning curve.
Me too!
"Have you heard about this thing called Home Automation"...
Documentation?
I have seen people stop their development of stuff since they made one big PR to finish their one thing
and when a PR does a million more things, we want to split it up
and that takes a different way of looking to stuff
Offcourse, that I know since I'm a developer.
I just want the integration merged so that we can have feedback and improve it over time
Right
But not everyone gets this, but this is the most important one
And I think the second thing, feel free to ask
Like, your device probably isn't special special, with this much integration, your use case already has been implemented somewhere
so always feel free to ask stuff
And I like to help out, so feel free to ask stuff whenever you feel like
Side note: I'm already using the underlying library in a flask application in my house since a couple of months.
Ah nice
Yeah, it it tested and works.
Anyway, I will push the changes now. You will probably get a ping via email. Thanks for now, really apreciate it!
Ok, so I'm not trusted ๐
Like, I was bothering Frenck enough until he gave me the role to post images haha
He usually doesn't like that tho
I got that feeling too ๐
Like, my traffic is still lowkey so I can just take these sidetrips to help people
It was like two messages. Since then I havent bothered him.
but in his position, I get it
Me too
So, you never answeded my question on the PR. Do you think we should remove async_turn_aux_heat_off?
oh I did not see that question
...and the other aux heat things
I could send you a screenshot of the question? ๐
Like I know that there is a discussion that it should be removed, but I don't know if there already is something in place to use now
It does not seem like it, and other integrations use it.
Oh right
I think I know what this means
As I see this is only a turn on/off thingy
So how I now interpret this is, we should add a switch to do aux heating
(in a separate PR)
So I think it would be best to remove this for now
Then I will remove the turn on/off aux heat as well.
And my last question. You wrote "...throw different parameters at your test...". Is this something I must do, or is it just a tip?
Like, python tests have 2 things that I really like
snapshot testing and parametrize
And I think it would cut down a lot in your testing code
And this is the point where I need to learn to give a dev some more freedom too ๐
I dont really follow. Can you point me in the right direction (documentation) of how to do that and what that means?
there is no real docs about this btw
but in your case, your test_form_invalid_device, test_form_connection_error, test_form_decoding_error and test_form_unexpected_error are the same, except for the error added in side_effect and the error message checked in result["errors"] = ...
So this way you can make it 1 test, and add the raised errors as parameters of the test
this way, if you ever have to change some logic in the config flow, you only have to update it once
I have no clue actually
Me neither
The thing is: We remove the auxiliary mode from the UI / more-info.
Thats in the proposal
If I remove | ClimateEntityFeature.AUX_HEAT and the properties for aux we get an even smaller PR
Yeah, from the UI
I think we should not add it, as people might start to rely on it and then we will remove it
like, I would prefer to use the switch platform for this then
All @sand wedgety for aux too?
And with the state its currently in, I think this is an easy merge
FFS
haha no problem
Like, I don't think we should use it now and rather make sure we give the user the right ropes directly
Removed it!
We can add a swith or whatever later.
At least now in the current state a user can 1: see the state of operation of the device and 2: change mode and temperature.
yep
Since you don't get your emails. The PR bot has pinged you. Ping!
I think it looks mergable
The remark about the parametrizing would clean up a lot of tests
and since you're only starting a flow twice with that change, the flow_id and _patch_update wouldn't be used as much as it would now, so you could inline that as well
I think those are the only 2 things
and the fact that today is the beta cut off, so I am not going to merge it before the beta cut as that gives a bit more work
Oh and I just noticed mock_serial_number is only mocking the lib in the config flow. I think you can move that to the config flow (or just remove it as fixture and use it in the tests itself)
Ok! Thanks for the feedback! I will look into that tomorrow.
Oh no. I broke the tests...
So, the thing is that the serial number was the title of the entity, but we changed that to be the device name. I tried mocking the device name as well but no luck. Pytest is kinda hard to understand... Will probably try something else tomorrow.
It looks hard to start with but it's quite doable tbh
Like, at first I was also wrestling a lot with it
lemme check what you patch
Haven't committed anything. Don't want to embarass myself ๐
haha, don't worry
Also, I have to go in a moment. Maybe I can ping you tomorrow?
yea sure
I mean I am in the office, but I still have HA dev env setup ๐
I didn't even setup the env for their applications yet
But there is one thing I notice and that is that the error is coming from the library. And we like tests to completely patch the library so the only thing we test is HA code
Exactly. Because now we miss a mock. There is an actual call to the library somewhere.
Yeah, I mean (beleive) what we patch calls to the library.
And we assert result2["title"] == "0000-0001" which was correct. But now the title is the device_name. We have to patch that too.
I see. But, I might also be too tired at the moment ๐