jugla / worldtidesinfocustom

world tides info custom component for home assistant
MIT License
28 stars 2 forks source link

Stopped working in HACS #14

Closed wildoracle closed 3 years ago

wildoracle commented 3 years ago

Describe the bug Was working fine before the recent update. Re-installed v6.0.0 and worked again.

To Reproduce Steps to reproduce the behavior:

  1. Updated to latest version v6.1.0 in HACS
  2. Stopped working

Expected behavior Add-on should provide data to sensors and camera object.

Desktop (please complete the following information):

Additional context Logger: homeassistant.components.sensor Source: custom_components/worldtidesinfocustom/live_position_management.py:62 Integration: Sensor (documentation, issues) First occurred: 7:53:37 PM (1 occurrences) Last logged: 7:53:37 PM

Error while setting up worldtidesinfocustom platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, *self.kwargs) File "/config/custom_components/worldtidesinfocustom/sensor.py", line 355, in setup_platform tides_sensors = setup_sensor( File "/config/custom_components/worldtidesinfocustom/sensor.py", line 165, in setup_sensor live_position_management = Live_Position_Management( File "/config/custom_components/worldtidesinfocustom/live_position_management.py", line 62, in init live_position_sensor_update_distance KM_PER_MI TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Logger: homeassistant.helpers.template Source: helpers/template.py:1210 First occurred: 7:53:47 PM (8 occurrences) Last logged: 7:53:47 PM

Template warning: 'as_timestamp' got invalid input '' when rendering template '{{ as_timestamp(states.sensor.holmes_tides.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2021.12 Template warning: 'timestamp_custom' got invalid input 'None' when rendering template '{{ as_timestamp(states.sensor.holmes_tides.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}' but no default was specified. Currently 'timestamp_custom' will return 'None', however this template will fail to render in Home Assistant core 2021.12 Template warning: 'as_timestamp' got invalid input '' when rendering template '{{ as_timestamp(states.sensor.holmes_tides.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2021.12 Template warning: 'timestamp_custom' got invalid input 'None' when rendering template '{{ as_timestamp(states.sensor.holmes_tides.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}' but no default was specified. Currently 'timestamp_custom' will return 'None', however this template will fail to render in Home Assistant core 2021.12

Logger: homeassistant.helpers.template Source: helpers/template.py:1612 First occurred: 7:53:47 PM (12 occurrences) Last logged: 7:53:47 PM

Template variable warning: 'mappingproxy object' has no attribute 'high_tide_time_utc' when rendering '{{ as_timestamp(states.sensor.holmes_tides.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}' Template variable warning: 'mappingproxy object' has no attribute 'low_tide_time_utc' when rendering '{{ as_timestamp(states.sensor.holmes_tides.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}' Template variable warning: 'mappingproxy object' has no attribute 'high_tide_time_utc' when rendering or compiling '' Template variable warning: 'mappingproxy object' has no attribute 'low_tide_time_utc' when rendering or compiling ''

jugla commented 3 years ago

Thanks for reporting . I will correct this evening.

jugla commented 3 years ago

Please can you tell me how you have declared the monitored location : UI or yaml ? Thanks in advance Philippe

wildoracle commented 3 years ago

In YAML (/config/sensor.yaml)

- platform: worldtidesinfocustom
  name: holmes_tides
  api_key: !secret worldtides_api_key
  latitude: OBSCURED
  longitude: OBSCURED
  plot_color: 109,153,237
  plot_background: 28,28,28

 - platform: template
  sensors:
    tide_holmes_next_high:
      value_template: '{{ as_timestamp(states.sensor.holmes_tides.attributes.high_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
      friendly_name: "Holmes Next High Tide"
    tide_holmes_next_low:
      value_template: '{{ as_timestamp(states.sensor.holmes_tides.attributes.low_tide_time_utc) | timestamp_custom("%a %d/%m/%Y %H:%M") }}'
      friendly_name: "Holmes Next Low Tide"
    tide_holmes_next_high_height:
      value_template: "{{ state_attr('sensor.holmes_tides','high_tide_height')  }}"
      friendly_name: "Holmes Next High Tide Height"
      unit_of_measurement: ft
    tide_holmes_next_low_height:
      value_template: "{{ state_attr('sensor.holmes_tides','low_tide_height')  }}"
      friendly_name: "Holmes Next Low Tide Height"
      unit_of_measurement: ft
    tide_holmes_credit:
      value_template: "{{ state_attr('sensor.holmes_tides','CreditCallUsed')  }}"
      friendly_name: "Holmes Tide Credit"
      unit_of_measurement: credit
    tide_holmes_current_height:
      value_template: "{{ state_attr('sensor.holmes_tides','current_height')  }}"
      friendly_name: "Holmes Tide Current Height"
      unit_of_measurement: ft
    tide_holmes_station:
      value_template: "{{ state_attr('sensor.holmes_tides','tidal_station_used')  }}"
      friendly_name: "Holmes Tide Station used"
    tide_holmes_coeff_mws:
      value_template: "{{ state_attr('sensor.holmes_tides','Coeff_resp_MWS')  }}"
      friendly_name: "Holmes Tide Coeff MWS"
      unit_of_measurement: "%"
    tide_holmes_amplitude:
      value_template: "{{ state_attr('sensor.holmes_tides','tide_amplitude')  }}"
      friendly_name: "Holmes Tide Amplitude"
      unit_of_measurement: ft

(sorry I was trying to use the insert code option but it didn't show correctly) Edited : @jugla , I have corrected to see as yaml

jugla commented 3 years ago

Thanks a lot !

jugla commented 3 years ago

Hello, Please test with 6.1.1 and tell me if it works on your side. Thanks in advance

wildoracle commented 3 years ago

YES! It works with v6.1.1 now. Excellent work! :)

jugla commented 3 years ago

Thanks for your message !