This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Help understanding why this was done this way
Post Body

Let me preface this with "I am a Programmer but not a Python Programmer".

I've got a Home Assistant script written in Python and want to understand why this was done. Since I need to modify this script I want to at least understand the code.

states = hass.states.get(entity_id) 
current_level = (states.attributes.get('brightness') or 0)   step

What is the purpose of the OR 0 statement part of the above? I'm assuming it has something to do with assuring that the brightness level is numeric before doing arithmetic on it.

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
52,449
Link Karma
11,708
Comment Karma
39,911
Profile updated: 2 days ago
Posts updated: 5 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago