Skip to content

Commit

Permalink
allow to set caching time for pictures seperately
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Aug 15, 2021
1 parent 86babea commit 788ab59
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
- No unreleased changes so far

## [0.14.0] - 2021-08-15
### Added
- Possibility to set caching time for picture downloads seperately

### Changed
- Longer caching (24h default) for picture downloads

## [0.13.2] - 2021-08-14
### Fixed
- Bug when downloading pictures fails
Expand Down Expand Up @@ -170,7 +177,8 @@ Send empty message when topic is disabled
## [0.1.0] - 2021-05-27
Initial release

[unreleased]: https://github.com/tillsteinbach/WeConnect-mqtt/compare/v0.13.2...HEAD
[unreleased]: https://github.com/tillsteinbach/WeConnect-mqtt/compare/v0.14.0...HEAD
[0.14.0]: https://github.com/tillsteinbach/WeConnect-mqtt/releases/tag/v0.14.0
[0.13.2]: https://github.com/tillsteinbach/WeConnect-mqtt/releases/tag/v0.13.2
[0.13.1]: https://github.com/tillsteinbach/WeConnect-mqtt/releases/tag/v0.13.1
[0.13.0]: https://github.com/tillsteinbach/WeConnect-mqtt/releases/tag/v0.13.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
weconnect==0.18.3
weconnect==0.19.0
paho-mqtt==1.5.1
8 changes: 5 additions & 3 deletions weconnect_mqtt/weconnect_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def main(): # noqa: C901 # pylint: disable=too-many-branches,too-many-statemen
default=None, required=False)
parser.add_argument('-i', '--interval', help='Query interval in seconds',
type=NumberRangeArgument(300, 3500), required=False, default=300)
parser.add_argument('--picture-cache-interval', dest='pictureCache', help='Picture download interval in seconds, this does not influence the interval in'
' which the status picture is updated', type=NumberRangeArgument(1), required=False, default=86400)
parser.add_argument('--prefix', help='MQTT topic prefix',
type=str, required=False, default='weconnect/0')
parser.add_argument('--ignore-for', dest='ignore', help='Ignore messages for first IGNORE seconds after subscribe to aviod '
Expand Down Expand Up @@ -201,7 +203,7 @@ def main(): # noqa: C901 # pylint: disable=too-many-branches,too-many-statemen
mqttCLient.username_pw_set(username=mqttusername, password=mqttpassword)

try:
mqttCLient.connectWeConnect(username=username, password=password)
mqttCLient.connectWeConnect(username=username, password=password, maxAgePictures=args.pictureCache)

if args.chargingLocation is not None:
latitude, longitude = args.chargingLocation
Expand Down Expand Up @@ -267,10 +269,10 @@ def disconnect(self, reasoncode=None, properties=None):
disconectPublish.wait_for_publish()
super().disconnect(reasoncode, properties)

def connectWeConnect(self, username, password):
def connectWeConnect(self, username, password, maxAgePictures):
LOG.info('Connect to WeConnect')
self.weConnect = weconnect.WeConnect(username=username, password=password, updateAfterLogin=False, updateCapabilities=self.updateCapabilities,
updatePictures=self.updatePictures)
updatePictures=self.updatePictures, maxAgePictures=maxAgePictures)
self.weConnect.addObserver(self.onWeConnectEvent, addressable.AddressableLeaf.ObserverEvent.VALUE_CHANGED
| addressable.AddressableLeaf.ObserverEvent.ENABLED | addressable.AddressableLeaf.ObserverEvent.DISABLED,
priority=addressable.AddressableLeaf.ObserverPriority.USER_MID)
Expand Down

0 comments on commit 788ab59

Please sign in to comment.