This commit adds a new component for communicating with mochad[1] a
socket interface for the CM15A and CM19A USB X10 controllers. This
commit leverages the pymochad library to interface with a mochad socket
either on a local or remote machine. Mochad is added as as a generic
platform because it supports multiple different classes of device,
however in this patch only the switch device implemented as a starting
point. Future patches will include other devices types. (although
that's dependent on someone gaining access to those)
[1] https://sourceforge.net/projects/mochad/
* Adds support for Pioneer AVR interface port number
https://community.home-assistant.io/t/support-for-pioneer-avr/503
telnetlib supports a port number so adding port as
an optional config element with a default of 23 resolves this.
* Adds timeout to Pioneer AVR
timeout in telnetlib defaults to socket._GLOBAL_DEFAULT_TIMEOUT
which is not a value, but rather a bare Object used for comparison.
telnetlib says the following about the timeout optional argument:
"The optional timeout parameter specifies a timeout in seconds
for blocking operations like the connection attempt (if not
specified, the global default timeout setting will be used)."
From the documentation for sockets:
"Sockets are by default always created in blocking mode"
Catching connect and timeout errors, logging to debug
and continuing.
* Catches timeout exceptions, logs and continues.
Instead of globally using StrictUndefined, introduce a filter that
will trigger a render failure on undefined variables.
Use as `{{ value_json.someval | is_defined }}`.
By not successfully rendering unknown objects to an empty string
the caller provided error_value actually gets used.
This allows, for instance, the MQTT sensor to retain its state when an
unexpected or unwanted message (#2733/#3834) is received.
* first version
* First draft component entities
* Change add_entities to callback from coroutine
* Fix bug add async_prepare_reload
* Group draft v1
* group async
* bugfix
* bugfix v2
* fix lint
* fix extract_entity_ids
* fix other things
* move get_component out of executor
* bugfix
* Address minor changes
* lint
* bugfix - should work now
* make group init async only
* change update handling to old stuff
* fix group handling, remove generator from init
* fix lint
* protect loop for spaming with updates
* fix lint
* update test_group
* fix
* update group handling
* fix __init__ async trouble
* move device_tracker to new layout
* lint
* fix group unittest
* Test with coroutine
* fix bug
* now it works 💯
* ups
* first part of suggestion
* add_entities to coroutine
* change group
* convert add async_add_entity to coroutine
* fix unit tests
* fix lint
* fix lint part 2
* fix wrong import delete
* change async_update_tracked_entity_ids to coroutine
* fix
* revert last change
* fix unittest entity id
* fix unittest
* fix unittest
* fix unittest entity_component
* fix group
* fix group_test
* try part 2 to fix test_group
* fix all entity_component
* rename _process_config
* Change Group to init with factory
* fix lint
* fix lint
* fix callback
* Tweak entity component and group
* More fixes
* Final fixes
* No longer needed blocks
* Address @bbangert comments
* Add test for group.stop
* More callbacks for automation
* Cache condition in helpers.Script
The caching is a simple in-memory, per-instance dictionary.
We use __str__ to format cache keys.
This naive implementation has some disadvantages (e.g., we won't be able
to cache two conditions that contain references to
distinct-but-equivalent object instances and we don't have any control
over the size of the condition cache), but for most simple use-cases the
approach should be good enough.
Resolves#3629
* Fix docstring style
* Add async_safe annotation
* More async_run_job
* coroutine -> async_save
* Lint
* Rename async_safe -> callback
* Add tests to core for different job types
* Add one more test with different type of callbacks
* Fix typing signature for callback methods
* Fix callback service executed method
* Fix method signatures for callback
* Template platforms: create_task instead of yield from
* Automation: less yielding, more create_tasking
* Helpers.script: less yielding, more create_tasking
* Deflake logbook test
* Deflake automation reload config test
* MQTT: Use async_add_job and threaded_listener_factory
* Deflake other logbook test
* lint
* Add test for automation trigger service
* MQTT client can be called from within async
* Add open/closed state mapping for open_cover and close_cover
* Add 'open', 'closed' for open/close_cover_tilt
* Revert "Add 'open', 'closed' for open/close_cover_tilt"
This reverts commit e45582d439.
* Allow reloading groups without restart
* Test to make sure automation listeners are removed.
* Remove unused imports for group tests
* Simplify group config validation
* Add prepare_reload function to entity component
* Migrate group to use entity_component.prepare_reload
* Migrate automation to use entity_component.prepare_reload
* Clean up group.get_entity_ids
* Use cv.boolean for group config validation
* Fix: Circular dependencies of internal files
* Change: dt.date for Date and dt.datetime for DateTime
* Use NewType if available
* FIX: Wrong version test
* Remove: Date and DateTime types due to error
* Change to HomeAssistantType
* General Improvement of Typing
* Improve typing config_validation
* Improve typing script
* General Typing Improvements
* Improve NewType check
* Improve typing db_migrator
* Improve util/__init__ typing
* Improve helpers/location typing
* Regroup imports and remove pylint: disable=ungrouped-imports
* General typing improvements
Add unit symbol constants
Initial unit system object
Import more constants
Pydoc for unit system file
Import constants for configuration validation
Unit system validation method
Typing for constants
Inches are valid lengths too
Typings
Change base class to dict - needed for remote api call serialization
Validation
Use dictionary keys
Defined unit systems
Update location util to use metric instead of us fahrenheit
Update constant imports
Import defined unit systems
Update configuration to use unit system
Update schema to use unit system
Update constants
Add imports to core for unit system and distance
Type for config
Default unit system
Convert distance from HASS instance
Update temperature conversion to use unit system
Update temperature conversion
Set unit system based on configuration
Set info unit system
Return unit system dictionary with config dictionary
Auto discover unit system
Update location test for use metric
Update forecast unit system
Update mold indicator unit system
Update thermostat unit system
Update thermostat demo test
Unit tests around unit system
Update test common hass configuration
Update configuration unit tests
There should always be a unit system!
Update core unit tests
Constants typing
Linting issues
Remove unused import
Update fitbit sensor to use application unit system
Update google travel time to use application unit system
Update configuration example
Update dht sensor
Update DHT temperature conversion to use the utility function
Update swagger config
Update my sensors metric flag
Update hvac component temperature conversion
HVAC conversion for temperature
Pull unit from sensor type map
Pull unit from sensor type map
Update the temper sensor unit
Update yWeather sensor unit
Update hvac demo unit test
Set unit test config unit system to metric
Use hass unit system length for default in proximity
Use the name of the system instead of temperature
Use constants from const
Unused import
Forecasted temperature
Fix calculation in case furthest distance is greater than 1000000 units
Remove unneeded constants
Set default length to km or miles
Use constants
Linting doesn't like importing just for typing
Fix reference
Test is expecting meters - set config to meters
Use constant
Use constant
PyDoc for unit test
Should be not in
Rename to units
Change unit system to be an object - not a dictionary
Return tuple in conversion
Move convert to temperature util
Temperature conversion is now in unit system
Update imports
Rename to units
Units is now an object
Use temperature util conversion
Unit system is now an object
Validate and convert unit system config
Return the scalar value in template distance
Test is expecting meters
Update unit tests around unit system
Distance util returns tuple
Fix location info test
Set units
Update unit tests
Convert distance
DOH
Pull out the scalar from the vector
Linting
I really hate python linting
Linting again
BLARG
Unit test documentation
Unit test around is metric flag
Break ternary statement into if/else blocks
Don't use dictionary - use members
is metric flag
Rename constants
Use is metric flag
Move constants to CONST file
Move to const file
Raise error if unit is not expected
Typing
No need to return unit since only performing conversion if it can work
Use constants
Line wrapping
Raise error if invalid value
Remove subscripts from conversion as they are no longer returned as tuples
No longer tuples
No longer tuples
Check for numeric type
Fix string format to use correct variable
Typing
Assert errors raised
Remove subscript
Only convert temperature if we know the unit
If no unit of measurement set - default to HASS config
Convert only if we know the unit
Remove subscription
Fix not in clause
Linting fixes
Wants a boolean
Clearer if-block
Check if the key is in the config first
Missed a couple expecting tuples
Backwards compatibility
No like-y ternary!
Error handling around state setting
Pretty unit system configuration validation
More tuple crap
Use is metric flag
Error handling around min/max temp
Explode if no unit
Pull unit from config
Celsius has a decimal
Unused import
Check if it's a temperature before we try to convert it to a temperature
Linting says too many statements - combine lat/long in a fairly reasonable manner
Backwards compatibility unit test
Better doc
* Add mysensors IR switch device and service
* Add MySensorsIRSwitch as child class to MySensorsSwitch.
* Add platform specific service mysensors_send_ir_code. Only call
device method in service function if device is IR device.
* Add service and required attribute to state helper to support scenes.
* Move V_IR_SEND type from sensor.mysensors to switch.mysensors
platform.
* Populate switch.services.yaml with service descriptions.
* Fix check of entity_id in service function
Since multiple entity_ids can be passed as service data, and the
entity_id service attribute is forced to a list by the service
validation schema, the check in the service function should iterate
over any entity ids.
* Allow time condition windows to cross midnight.
* Address comments.
Fold _in_time_window back into the time() condition test.
Use specific time values to test the time window.
"unix" timestamp is number of seconds since Jan 1, 1970 UTC.
This allows scripts that use templates to generate time
deltas in seconds if desired from state attributes such
as last_updated.
Some examples:
timestamp now is
{{ as_timestamp(now) }}
timstamp of last change is
{{ as_timestamp(states.binary_sensor.garage_door.last_changed) }}
seconds since last change is
{{ as_timestamp(now) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}
Accept delay configuration even when someone forgets to indent the time
specification.
Also removed 'weeks' and 'microseconds' from acceptable delay values.
There is a new homeassistant release every 2 weeks and running scripts
are not persisting across restarts. And there is still the option of
using (weeks*7) days if the long delay is really necessary.
And if someone really depends on microsecond delay precision we are
unlikely to be able to provide this accuracy, even milliseconds is
suspect for that matter but will at least allow us to specify some
subsecond delay.
* Add tests to reach full coverage for helpers/state.py.
* Refactor reproduce_state function in helpers/state.py. Add two dicts,
as global constants, service_attributes and service_to_state. Use
these in combination with the dict of services per domain from
ServiceRegistry, to find the correct service to use in a scene state
change.
* Use break statement in for loop, to break if service was selected
to update state, in preference to update state attributes, ie state
update takes precedence.
* Add ATTR_CODE and ATTR_CODE_FORMAT in const. Import these in
alarm_control_panel and lock platforms instead of making duplicate
constants in multiple modules.
* Use ATTR_MEDIA_CONTENT_TYPE and ATTR_MEDIA_CONTENT_ID in media_player
platform in SERVICE_PLAY_MEDIA and play_media methods, instead of
'media_type' and 'media_id'.
* Fix PEP257 in modified files.
This adds state_as_number(), a helper method that tries to interpret
state as a number, for cases we can predict. It's a generalization of
what is copy-and-paste-ed into multiple other places.
* Add 'available' property. Return True by default.
* Use new property in update_ha_state(). If available is False, set
state to 'unavailable', through constant.
* Add STATE_UNAVAILABLE constant 'unavailable' in const.py.
* Fix docstrings in entity.py and const.py, according to PEP257.
Ignore D203 and D105.
1. service decorator was overwriting the function name with one of its
arguments.
2. Accidentally left an extra argument in track_sunrise.
3. Added track_utc_time_change decorator.
1. Added HASS to the arguments for callbacks that are created with
event decorators.
2. Added a service decorator.
3. Updated example.py in the example config to use the event decorators.
This revision of event decorators removes much of the complexity. The
decorated functions are no longer wrapped with a class that tracks
last_run, etc. Bootstrap now gives hass to the event_decorators module
before initializing components so the decorators no longer require
activation.
1) helpers/event should not import the sun component unless it is
requested. This prevents circular import.
2) fixed import typo in bootstrap
2) bootstrap cannot import event_decorators until it is needed because
this leads to a circular import.
Created event decorators for custom components. Decorators were created
for the events: track_state_change, track_sunrise, track_sunset, and
track_time_change.
The toggle function in the Entity ABC was using state == STATE_ON to
determine whether the entity was on. This was revised to use the is_on
property instead.
Rewrote imports of exceptions to be from the exceptions module.
Made nmap scanner check for libnmap dependency without crashing.
Various flake8 and pylint updates.
With the recent change to YAML, it is now easier to support lists by
default. Any config section that previous relied on the "domain",
"domain 1", "domain 2" format can now use YAML lists instead. The old
format is also still supported.