SpaceX sensors: Starman and next rocket launch


#23

I modified the Xaiomi Vacum card to suit this sensor in lovelace.

spacex-lovelace

spacex-lovelace2

Also added in the rounded corner card as well for the second screenshot.

Can share the code if anyone is interested.


#24

I think I found the problem: https://www.home-assistant.io/docs/configuration/templating/#templates-using-now

I have another Automation with a time based offset and it’s working fine. It is using the sensor.time entity. Maybe try to convert the spacex timestamp in a format that you can compare to sensor.time. Maybe it is helpful to you:

- alias: Aufstehlicht
  initial_state: True
  trigger:
  - platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.wecker_uhrzeit.attributes.timestamp | int - 120 ) | timestamp_custom('%H:%M', False) }}"
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.workday_sensor
      state: 'on'
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
  - service: script.turn_on
    data_template:
      entity_id: >
        {% if is_state('input_select.wecker_raumauswahl','Schlafzimmer') %} script.sz_wakeup_light
        {% elif is_state('input_select.wecker_raumauswahl','Room2') %} script.r2_wakeup_light
        {% endif %}

#25

Please share. :slight_smile:


#26

please see approx. 6cm above :slight_smile:


#27

Amazing, thank you very much, managed to get it working with this code,

  - platform: template
    value_template: "{{ states('sensor.time') == (states.sensor.spacex_next_launch_time.attributes | int - 600 ) | timestamp_custom('%H:%M', False) }}"

Just put it to 955.500 seconds, to test, and it just popped up with a pushbullet alert for me.

Thank you again.


#28

This is the current code with the rounded corners I am using.

and you will need the card-modder custom card for the rounded corners, you can easily find it on here with a search.

And here is the background I am using.

  - type: custom:card-modder
    card:  
      type: picture-elements
      image: /local/spacex.jpg
      elements:
      - type: state-label
        entity: sensor.spacex_next_launch_day
        style:
          top: 20%
          left: 48%
          color: rgb(255, 255, 255)
          transform: translate(0%,-50%)
          pointer-events: none
          text-shadow: 1px 1px black
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          border-left-style: solid
          border-color: rgb(34, 154, 210)
          background-color: rgb(54, 65, 78)
          border-radius: 5px
          opacity: 0.8
      - type: state-label
        entity: sensor.spacex_next_launch_time
        style:
          top: 33%
          left: 48%
          color: rgb(255, 255, 255)
          transform: translate(0%,-50%)
          pointer-events: none
          text-shadow: 1px 1px black
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          border-left-style: solid
          border-color: rgb(34, 154, 210)
          background-color: rgb(54, 65, 78)
          border-radius: 5px
          opacity: 0.8
      - type: state-label
        entity: sensor.spacex_next_launch_site
        style:
          top: 7%
          left: 8%
          color: rgb(255, 255, 255)
          transform: translate(0%,-50%)
          pointer-events: none
          text-shadow: 1px 1px black
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          border-left-style: solid
          border-color: rgb(34, 154, 210)
          background-color: rgb(54, 65, 78)
          border-radius: 5px
          opacity: 0.8
      - type: state-label
        entity: sensor.spacex_next_rocket
        style:
          top: 46%
          left: 48%
          color: rgb(255, 255, 255)
          transform: translate(0%,-50%)
          pointer-events: none
          text-shadow: 1px 1px black
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          border-left-style: solid
          border-color: rgb(34, 154, 210)
          background-color: rgb(54, 65, 78)
          border-radius: 5px
          opacity: 0.8
      - type: state-label
        entity: sensor.spacex_next_mission_name
        style:
          top: 59%
          left: 48%
          color: rgb(255, 255, 255)
          transform: translate(0%,-50%)
          pointer-events: none
          text-shadow: 1px 1px black
          font-family: Trebuchet MS
          font-size: 90%
          font-weight: bold
          border-left-style: solid
          border-color: rgb(34, 154, 210)
          background-color: rgb(54, 65, 78)
          border-radius: 5px
          opacity: 0.8
      style:
        - text-transform: none
    style:
      background-repeat: no-repeat
      background-color: rgba(50,50,50,0.3)
      background-size: 100% 68px
      border-radius: 20px
      border: solid 1px rgba(100,100,100,0.3)
      box-shadow: 3px 3px rgba(0,0,0,0.4)

#29

Thank you very much!


#30

So it seems that the automation just triggered for me at 1hr to midnight, and then 10 mins to midnight, not sure what happened there, will have to have a look into it.